Are there any portable versions of Git for Mac OSX?
Asked Answered
L

4

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.

Limn answered 22/1, 2013 at 19:53 Comment(13)
Why can't you just copy it from /usr/bin?Cordwood
Duplicate of #5893195 ?Retinitis
@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?Limn
@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.Limn
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.Capitulum
@Capitulum The problem is that I don't have the /path/to/git/ part. :/ The OSX download that they have on git-scm.com is an installer and I can't run it with out admin privileges.Limn
@jen-montes You could try a pure python install of mercurial and then try adding the hg-git plugin.Capitulum
Perhaps some kind soul (not me, I don't have a Mac) can copy their own installed git files to a server somewhere.Selector
@Capitulum 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.Limn
@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.Limn
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.)Selector
Everyone should have make available. That is not a valid excuse.Dett
@KeithThompson, people don't usually know, that's the point of that Google Search. Works more for windows than for Mac.Sibship
L
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.

Limn answered 23/1, 2013 at 18:28 Comment(2)
The warning can be avoided if you set GIT_EXEC_PATH, see stackoverflow.com/questions/15787385/#answer-15790100 for details.Yancey
@Jen, https://www.quora.com/unanswered/Git-shouldnt-you-do-export-PATH-foo-PATH-instead-of-export-PATH-PATH-fooSibship
D
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.

Detector answered 2/4, 2015 at 3:5 Comment(0)
D
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.

Deryl answered 23/1, 2013 at 2:0 Comment(4)
you can create public gists for those, although it isn't clear how much of that is specific to Mountain LionArrack
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.Limn
@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.Deryl
@Deryl 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.Limn
G
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.

Giralda answered 23/1, 2013 at 2:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.