---
title: "GIT"
canonical: "https://kb.uconn.edu/space/SH/26033947030/GIT"
format: markdown
---
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
```

You can read more about this workflow with the [GitHub interactive tutorial](https://try.github.io/) and the [Software Carpentry lesson](https://swcarpentry.github.io/git-novice/).

## `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](http://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](https://help.github.com/articles/generating-ssh-keys/) to setup your `ssh` keys and add the public key to your GitHub repository.