Skip to content

Setting up git and github

mdavy86 edited this page Nov 12, 2014 · 2 revisions

Setting up git and github

Creating a github account

First go to github and create an account

Linux VM

You will never be able to push commits back to github from a cloned repository until you set up your ssh public key in your settings.

After logging into NZGL via VPN, make a public/private ssh key for your vitual machine and github from the terminal prompt;

## Make public/private ssh key
cd ~/.ssh
ssh-keygen -t rsa -b 2048 -f ~/.ssh/github_nzgl_rsa

## Copy the public key to github
cat ~/.ssh/github_nzgl_rsa.pub

Add the public key by copying its entire contents to your github account https://github.com/settings/ssh

The following sanity check makes sure what you have done works;

$ ssh -T git@github.com
Hi [USER]! You've successfully authenticated, but GitHub does not provide shell access.

For further information see instructions on setting up ssh keys.

Now to make your configuration more usable. Copy the entire contents of the following block into your linux VM terminal window, it will append the Host github.com to your ~/.ssh/config file;

## HERE doc to append a new profile to ~/.ssh/config
cat - >> ~/.ssh/config << EOF

Host github.com
    HostName ssh.github.com
    HostKeyAlias github
    User git
    IdentityFile ~/.ssh/github_nzgl.rsa

EOF

The following sanity check should now connect automatically;

$ ssh -T git@github.com
Hi [USER]! You've successfully authenticated, but GitHub does not provide shell access.

Setting up ~.gitconfig profile

Before using git you should set up your account name, email address and credentials

# Sets the default name for git to use when you commit
git config --global user.name "Your Name Here"

# Sets the default email for git to use when you commit
git config --global user.email "your_email@youremail.com"

A sanity check to make sure that has worked is to check the contents of ~/.gitconfig file and make sure that your [user] stanza has been updated.

cat ~/.gitconfig

Windows client machines

Download git

Following the instructions at set-up-git to download and setup git.

While we are at it, you can configure git for windows. Users may need to make git aware of self signed certificates by adding the following to their gitconfig file;

## This will add to the [http] stanza in your .gitconfig
git config --global http.sslCAinfo "/bin/curl-ca-bundle.crt"