macosgitportable-executableportable-applications

Are there any portable versions of Git for Mac OSX?


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.


Solution

  • Getting the Binary

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

    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!

    Setting Up Git-Core

    ./bin/git depends on other tools in order to work. Typically, it finds these tools in /usr/local/git/share/git-core/. So you may encounter errors and warnings when running your portable git on its own such as these Jen found:

    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.

    To mitigate this as @thomas-s suggests, we need to set the GIT_EXEC_PATH to the path of your portable's git-core in your shell's environment (.zshrc, .bash_profile, .bashrc, and so on). Or, if you're scripting you can create a project specific shell environment and set GIT_EXEC_PATH there.