Fixing Git SSH After Upgrading to macOS Sierra

Yes. I’m a latecomer to the Sierra game (due mainly to an audio hardware driver I had to wait on to be upgraded to Sierra, which finally was updated but probably won’t be updated to High Sierra…), and most developers have probably already run into this problem and have dealt with it accordingly. However, I thought it might be a good idea to capture this here for posterity…

Just this morning, immediately after upgrading to macOS Sierra, I experienced a problem by which Git began incessantly asking for my passphrase. This was an unwelcome surprise to me, but thankfully there’s a reasonably simple fix, thanks to this SuperUser suggestion:

macOS keeps asking my ssh passphrase since I updated to Sierra – Super User

In the latest version of macOS (10.12.2), this is easy to fix. Just edit your ~/.ssh/config and enable the UseKeychain option:

Host *
 UseKeychain yes

There is no need to change anything else. Now everything works the way it used to work before the latest updates. You do not need to add keys to ssh-agent.

In my case, I couldn’t just edit the config file in question, because it didn’t exist. Therefore, I had to create the config file in my ~/.ssh directory with the information mentioned in the SuperUser post.

Thankfully, after creating the file, re-launching Terminal, and entering my credentials one final time, it seems to have worked and Git is happy again.

Git: The difference between Pull and Fetch

I really appreciated how Greg Hewgill summarized the difference between the two Git functions “Pull” and “Fetch” on Stackoverflow:

In the simplest terms, “git pull” does a “git fetch” followed by a “git merge”.

You can do a “git fetch” at any time to update your local copy of a remote branch. This operation never changes any of your own branches and is safe to do without changing your working copy. I have even heard of people running “git fetch” periodically in a cron job in the background (although I wouldn’t recommend doing this).

A “git pull” is what you would do to bring your repository up to date with a remote repository.