Throughout the chapter on working with remotes, every time we want to communicate with the
remote repository, we had to enter our credentials again, our username and our password, and
we had to do it every single time, even if we were just doing git fetch, we had to login
to that server again.
It doesn't take very long before you get really sick of typing your username and password
over and over again, so you're going to want a solution to that.
There are basically two ways to do it.
One is to have a keychain program that will store your username and password, and then
Git will be able to go to the keychain program, get your username and password, and send it
to the remote along with your request.
If you decide you want to do it this way, GitHub has a help article that can help you to do it.
They have a page on setting up Git, it's help.github.com/articles/ set-up-git, and then if you add the # sign, password-caching,
it will take you right to the part of the page about caching your password in a keychain.
And it uses OS X keychain, which of course is for Mac.
You need to have Git 1.7 10 or newer to use it, and you need to be on a Mac.
Then you can follow their instructions for getting that set up.
And then it will remember your username and password in your Mac OS keychain.
That's the keychain that you can see in your application utilities folder.
If you aren't on a Mac, or if you decide not to do it this way, you can also use SSH Keys,
and this is the way that I actually do it.
The idea behind SSH Keys is different than caching your password in a keychain.
Instead, we have a little bit of code, an actual file that resides on my computer.
And I take that same code, or actually a complementary part of it, and put it up on the GitHub server.
Then when I go to make a request, Git automatically sends that bit of code along with the request
and uses those to authenticate me and see that I am who I say that I am.
There are many resources out there on the web that can help you to get SSH Keys set
up and to get them working with whatever host you provide.
GitHub also has a help article, and that is help.github.com/articles/generating-ssh-keys.
And you can see here that you can then pick between Mac, Windows, Linux or All, and it
will give you step-by-step instructions on how to get those set up.
One thing that you should note though that's very important is that when you go to the
project, Git has http selected by default as the address format here for the repository.
If you're using SSH, you need to press this button first to get it in SSH format.
If you are going to type it each time or if you are going to use a keychain, you'll want to use http,
but if you're using SSH Keys, you'll want to switch and use that.
Whichever way you choose, you'll save yourself a lot of time by not having to type username
and password every time you want to connect to the remote server.