7

I'd like to be able to do some development work on public/borrowed computers (where I have no root privileges) and I've managed to get most of my tools working off of a USB stick but I still haven't found a Git solution.

The portable versions of Git that I have found are Windows-only. Do you know of any Mac alternatives?

EDIT: I've gotten a few suggestions to just copy my current installation of git from /usr/bin and put that on a USB drive. That's a great idea but I don't have a current installation of git to copy from. I won't have my own computer back for a couple of weeks.

Would you happen to know where I could grab a pre-compiled version of git for OSX? I don't have access to homebrew or... anything really. Ideally I could just grab a zip file from somewhere and dump it on my USB stick.

Jen Garcia
  • 699
  • 5
  • 18
  • Why can't you just copy it from `/usr/bin`? – Carl Norum Jan 22 '13 at 19:55
  • Duplicate of http://stackoverflow.com/questions/5892695/can-i-use-git-without-installing ? – Jonathan Wren Jan 22 '13 at 19:57
  • @CarlNorum I don't have anywhere to copy it from since I don't have a home computer at the moment. Where can I get it? – Jen Garcia Jan 22 '13 at 20:08
  • 1
    @Duotrigesimal The answers to that question involve compiling from source, which I can't do at the moment (I do JS development so I don't have C dev tools), or using JGit, doesn't have as many commands/options. – Jen Garcia Jan 22 '13 at 20:12
  • Have your tried mounting the usb stick and trying export PATH=$PATH:/path/to/git/on/usb/stick? Might work and allow you to access git properly. – bms Jan 22 '13 at 20:14
  • @bms The problem is that I don't have the /path/to/git/ part. :/ The OSX download that they have on http://git-scm.com/ is an installer and I can't run it with out admin privileges. – Jen Garcia Jan 22 '13 at 20:17
  • @jen-montes You could try [a pure python install of mercurial](http://vilimpoc.org/blog/2010/10/04/installing-mercurial-without-admin-rights-and-no-c-compiler/) and then try adding the [hg-git plugin](http://hg-git.github.com/). – bms Jan 22 '13 at 20:40
  • Perhaps some kind soul (not me, I don't have a Mac) can copy their own installed git files to a server somewhere. – Keith Thompson Jan 23 '13 at 00:13
  • @bms While technically not in the scope of the question (I prefer git), I still gave your suggestion a shot. Sadly, the pure python install instructions require that I `make` the Mercurial installation, but I don't have that command available. – Jen Garcia Jan 23 '13 at 00:25
  • @KeithThompson I hacked a Google search together to try to find it somewhere: `-inurl:(htm|html|php) intitle:"index of" "last modified" "parent directory" description size "usr/bin" hdiutil git`. I included `hdiutil` because I think it's unique to Macs and it would also live in `/usr/bin`, but no results. – Jen Garcia Jan 23 '13 at 00:54
  • Not surprising; there's no particular reason for someone to copy their Git executables to a server (outside your specific unusual circumstances). My suggestion was that somebody reading these comments might be willing to do it for you. (I'd do it myself if I had a Mac.) – Keith Thompson Jan 23 '13 at 01:13
  • Everyone should have `make` available. That is not a valid excuse. – Mahmoud Al-Qudsi Jan 23 '13 at 02:03
  • @KeithThompson, people don't usually know, that's the point of that Google Search. Works more for windows than for Mac. – Pacerier Jul 13 '19 at 00:09

4 Answers4

8

I've managed to put together a solution based on ideas from several different people (thanks to all of you):

  • Download the Git binary for Mac OSX from git-scm.com. The downloaded DMG contains a PKG file.
  • Unpack the PKG file with unpkg or something similar. (This step is necessary because normally PKG files can only be installed with root privileges.)
  • Drop the etc and git folders that were just unpacked onto your USB stick.

Now, whenever you plug in your USB stick, just make sure to put the location of the git directory on your PATH (like this: export PATH=$PATH:/path/to/git/on/usb/stick) and you'll be good to go!

NOTE: I've tested many of the git commands using this method and most seem to work without any issues. However, git init will complain like this: warning: templates not found /usr/local/git/share/git-core/templates. Not surprising since the templates are actually on your USB stick and not /usr/local. Despite this warning my repos seem to be working just fine.

Jen Garcia
  • 699
  • 5
  • 18
  • 2
    The warning can be avoided if you set `GIT_EXEC_PATH`, see http://stackoverflow.com/questions/15787385/#answer-15790100 for details. – Thomas S. Oct 31 '13 at 09:34
  • @Jen, [https://www.quora.com/unanswered/Git-shouldnt-you-do-export-PATH-foo-PATH-instead-of-export-PATH-PATH-foo](https://www.quora.com/unanswered/Git-shouldnt-you-do-export-PATH-foo-PATH-instead-of-export-PATH-PATH-foo) – Pacerier Jul 20 '19 at 08:37
3

Add a environmental variable GIT_TEMPLATE_DIR to quote the documentation

The template directory contains files and directories that will be copied to the $GIT_DIR after it is created.

The template directory will be one of the following (in order):

the argument given with the --template option;

the contents of the $GIT_TEMPLATE_DIR environment variable;

the init.templatedir configuration variable; or

the default template directory: /usr/share/git-core/templates.

manu datta
  • 141
  • 2
  • 4
0

I've uploaded my /usr/bin/git and /usr/bin/git-shell to

You can try those, but I have no idea if this approach is likely to work. (There are no interesting shared-library dependencies reported by otool -L, but I don't know what else might theoretically go wrong with the idea.)

FWIW, I use Mac OS X 10.8.2 and git version 1.7.10.2 (Apple Git-33).

Not sure if this is appropriate as an "answer", since I don't plan to leave those links working indefinitely. Maybe I (or someone) can delete this answer in a month or two.

Quuxplusone
  • 23,928
  • 8
  • 94
  • 159
  • you can create public gists for those, although it isn't clear how much of that is specific to Mountain Lion – prusswan Jan 23 '13 at 02:06
  • 1
    Hey! Thanks for doing this! Definitely helpful for the short-term, but you're right: it's not really an appropriate answer. You still get karma points though. – Jen Garcia Jan 23 '13 at 18:10
  • @JenMontes Did you try putting these exact binaries on a USB stick and did it actually work for you? or did you run into any of those "unknown unknowns"? — I did see your final answer, which involved git binaries (from a more trusted source :)), so I guess the approach does work. – Quuxplusone Jan 23 '13 at 23:19
  • @Quuxplusone Your `git` binary did work very well, though I would get the same templates warning when I tried `git init`. I don't really use `git-shell` much, but I made a `git-shell-commands` folder in my home directory and it seemed to work like it's supposed to. – Jen Garcia Jan 24 '13 at 14:56
0

Apple's command line tools for developers include git, I believe. You can find them on http://developer.apple.com/; you might need a free developer account. They package will want to install to /usr/bin etc., but you should be able to use pax to extract the contents wherever you want.

LaC
  • 12,624
  • 5
  • 39
  • 38