Git
Last updated
Last updated
If you installed Xcode from the you should skip this task, otherwise run:
When done, to test that it installed properly you can run:
And which git
should output /usr/local/bin/git
.
Next, we'll define your Git user (should be the same name and email you use for ):
They will get added to your .gitconfig
file.
To push code to your GitHub repositories, we're going to use the recommended HTTPS method (versus SSH). To prevent git
from asking for your username and password every time you push a commit you can cache your credentials by running the following command, as described in the .
We suggest to use an SSH Key for each account.
First, we need to check for existing SSH keys on your computer. We do this by running:
Check the directory listing to see if you have files named either id_rsa.pub
or id_dsa.pub
. If you already have this you need to use a different name for your new SSH Key.
Change the default location and name and press enter.
Enter and re-enter a passphrase when prompted. The command creates your identity with its public and private keys.
Now list the contents of ~/.ssh
to view the key files.
Run the following commands to make sure that the ssh-agent
is running.
No matter what operating system version you run you need to run this command to complete this step:
To make sure that your key was added to the agent you can run:
The last step is to let GitHub know about your SSH key. Run this command to copy your key to your clipboard:
Return to your terminal window and run the following command:
You may see a warning like this:
Verify that the fingerprint in the message you see matches, then type yes
:
You can generate and add your Key to ssh-agent with the same process used for GitHub. For add your public key to your account you need to follow these steps:
From Bitbucket, choose Bitbucket settings from your avatar in the lower left. The Account settings page opens.
Click SSH Keys.
In your terminal copy the public key with this command: pbcopy < ~/.ssh/<your pub key name>.pub
From BitBucket, click Add key.
Enter a Label for the Key.
Paste the copied public key into the SSH Key field.
Click Save.
Return to your terminal window and verify your configuration and username by entering the following command: ssh -T git@bitbucket.org
The command message tells you which of your Bitbucket accounts can log in with that key.
Then go to GitHub and . Paste your key in the "Key" text box and pick a name that represents the computer you're currently using.
Verify that the resulting message contains your username. If you receive a "permission denied" message, see .
If you get an error message with Permission denied (publickey)
, check the page for help.
Now that you've got an SSH key set up, use the SSH URL the next time you . If you already have a repository that you cloned over HTTPS, to use its SSH URL.