Git is the most universally adopted version control software and is often used alongside remote repositories like GitHub and GitLab for developing, managing and distributing code.
Full Git documentation can be found here, or using
In order to pull from a private repo, or push changes to a remote, you need to authenticate yourself on the cluster.
GitHub removed support for password authentication on August 13, 2021. Using a SSH key is now the easiest way to set up authentication.
SSH Authentication (GitHub)
More information can be found in the GitHub documentation.
- On the NeSI cluster, run the command
ssh-keygen -t ed25519 -C "firstname.lastname@example.org"
- When prompted for a file name, press
enter. When prompted for a passcode, press enter twice more.
- Open up the newly created .pub key with the command
cat ~/.ssh/id_ed25519.pub(or whatever you named the key). It should look something like:
ssh-ed25519 ABCDEFGKSAfjksjafkjsaLJfakjJFCopy the whole key.
Now log in to your github account. In the upper-right corner of any page, click your profile photo click Settings.
In the "Access" section of the sidebar, click SSH and GPG keys.
Click New SSH key or Add SSH key.
In the "Title" field, put "Mahuika" or "NeSI".
Paste your key into the "Key" field.
Click Add SSH key.
- Switching back to your terminal on the cluster, you can test your connection with the command
ssh -T email@example.comYou may be promted to authenticate, if so type 'yes'
If everything is working, you should see the message
Hi User! You've successfully authenticated, but GitHub does not provide shell access.
You can create a repository with either of the following commands.
||Copies a remote repository into your current directory.|
||Creates a new empty repo in your current directory.|
||Adds all python files in the current directory to the staging area.|
||Lists changes in working directory, and staged files.|
||Records everything in the staging area to your repository. The default text editor will prompt you for a commit message.|
||Records everything in the staging area to your repository with the commit message "Commit message"|
||Modify last commit instead of creating a new one. Useful for fixing small mistakes.|
||Prints commit history of repo.|
||Prints commit history of
||Removes all files from staging area. (Opposite of
By default, fetch, pull and push will operate on the origin repo. This will be the repo you cloned from, or set manually using
git branch --set-upstream-to
||Gets status of 'origin'. git fetch does not change your working directory or local repository (see
||Get status of
||Incorporates changes from 'origin' into local repo.|
||Incorporates changes from
||Incorporates changes from local repo into 'origin'.|
||Incorporates changes from local repo into
If you are working without collaborators, there should be no reason to have a conflict between your local and your remote repo. Make sure you always git pull when starting work on your local and git push when finished, this will save you wasting time resolving unnecessary merges.
At an introductory level, it is best to avoid workflows that lead to multiple branches, or requires merging.
||Create new branch
||Switch to editing branch