Git version control

From Storrs HPC Wiki
Revision as of 17:41, 19 February 2016 by Cdk10001 (talk | contribs)
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<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 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:\/\/\//' .git/config
grep url .git/config  # See the change

git push gives Permission denied (publickey)

$ git push -u origin master
Warning: Permanently added ',' (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.