Git version control

From Storrs HPC Wiki
Jump to: navigation, search

Best practice in science is to use version control when doing any programming. To use Git version control, go to the root directory of your folder of interest and create a new repository with:

git init

Then add files, and commit them. You can read more about this workflow with the GitHub interactive tutorial and the Software Carpentry lesson.

git push gives fatal: HTTP request failed

GitHub recommends using HTTPs when pushing to their repo. However on the HPC Cluster, this returns an error:

$ git push -u origin master
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/<username>/<repo>.git/info/refs

fatal: HTTP request failed

To get around this, one should instead use git@ instead of https:// and : instead of the trailing / in github.com. You can do both these things but just running this command in the root of your git repo:

sed -ie '/url[ \t]*=[ \t]*/s/https:\/\/github.com\//git@github.com:/' .git/config
grep url .git/config  # See the change


Alternatively, when cloning the repository just use ssl instead:

$ git clone git@github.com:<user>/<repository>.git

git push gives Permission denied (publickey)

$ git push -u origin master
Warning: Permanently added 'github.com,192.30.252.130' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

Follow the GitHub instructions to setup your ssh keys and add the public key to your GitHub repository.