-
Notifications
You must be signed in to change notification settings - Fork 2
Keeping Git and Git LFS Updated
I highly recommend keep software up to date, and one of the easiest ways to do this is to use a package manager of sorts. On a Mac, I use Homebrew.
- Make sure you have Xcode downloaded. You can get it through the App Store.
- In Terminal, enter the following:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Now that you have Homebrew installed, you can get git-lfs installed by entering the following into Terminal:
brew install git-lfs
Git LFS requires Git v 1.8.2 or later. To check your version of Git, type in Terminal git version. The following steps apply to Git LFS, too (replace occurrences of git with git-lfs for all calls to brew). Type git lfs version to see the Git LFS version.
Never used Git Before (Homebrew Install)
If you've never used Git before, it's easy to get started. Enter the following into Terminal:
brew update # make sure Homebrew is up to date
brew install git # install git via homebrew
brew link git # might tell you this has already been done
Next, you should get set up with a credential manager (Note not relevant for git-lfs)
git config --global user.name "yourGitHubName" # use your GitHub account name
git config --global user.email [email protected]
git credential-osxkeychain # should see stuff like usage: git crediential-osxkeychain ...
git config --global credential.helper osxkeychain # should see nothing
Next time you try to do something with git, you'll enter your name and pass, then good to go from now on!
Update Homebrew Installation of Git
If you have installed Git through Homebrew, but need to update your Git:
brew update # update homebrew
brew upgrade git # update git
brew link git # make sure it's linked; can even follow the unlink then link instructions
Start Managing Git w/ Homebrew (used something else previously)
If you have previously installed Git through means other than Homebrew, and want to start managing with Homebrew:
brew update # makes sure Homebrew is up to date
brew install git # installs Git
echo $PATH # if`/usr/local/bin` isn't listed before `/usr/bin`, your system won't look to the Homebrew versino of Git
Changing your $PATH variable
This can be tricky, in my experience. The trick is getting the changes to stick around. This means editing a profile file somewhere, but the name of the file depends on the system, and they aren't mutually exclusive:
-
~./bash_profile(I have this on my Mac) -
~/.profile(I've never seen this) -
~/.bashrc(I've seen this on Linux, but not on my Mac)
Because of that confusion, one strategy is to not bother putting it in a file explicitly. I can't remember how well this works anymore, but, in Terminal try:
export PATH="$(brew --prefix)/bin:$PATH"
The goal there is to add the location of Homebrew's installation of Git near the front of $PATH, thereby giving it precedence over any other installations of Git that might be on your system. So we can test if your system is preferring the right version of Git by first restarting Terminal, then:
which git # hopefully the output is `/usr/local/bin/git`
git version # hopefully the output is the latest version
If these output are correct, you're good to go!
If that method doesn't work, we can change the contents of one of those profile files. These files are read, I believe, on Terminal startup. Vim is an in-terminal text editor. Funny note: Vim can be hard to work with, but you can actually change which text editors are used by Terminal, and which are accessible ... but to do that you have to edit this same profile file! (Feel free to ask Ryan how he did this). OK, back to the goal, fixing the $PATH variable; in Terminal:
vim ~/.bash_profile
# can move with arrow keys
# hit 'i' to go to insert mode
# in insert mode, type freely
# hit 'Esc' to exit insert mode
# ':wq' write the changes then quits vim
When Vim is open, add the line export PATH="$(brew --prefix)/bin:$PATH" near the bottom of the file.
See ways to edit the $PATH variable here
After editing the file, reload the profile and check the variable with the following:
source ~/.bash_profile
echo $PATH
If those steps don't work, look at this Stack Overflow question, and the answers within
If those all fail, you can also try
brew uninstall git
brew install git
brew link git # can try the unlknk && link too
Steps for updating Git via Homebrew apply equally to updating/ installing Git LFS via Homebrew.