Command glossary

Author

Government Analysis Function and ONS Data Science Campus

In this section is useful commands that can be quickly referenced once you are using Git after the course. For a more comprehensive reference, gitexplorer is an excellent resource.

Command Purpose
git init initialises a git repo in your current directory
git add <file name> adds a specific file to be tracked by git and any changes made
git add . adds all untracked files and changes made
git status informs you whether changes have been made to the repo (new, untracked, deleted or renamed files)
git commit commits all changes / new files added
git commit -m "your message here" commits all changes / new files with a user defined message
git checkout <branch name> moves to the specified repo
git checkout -b <branch name> creates an new branch with a specified name and moves to it
git merge <source branch> <target branch> attempts to merge the source branch with the target branch, you must be on the target branch to do this
git branch -d <branch name> deletes the branch if it has been merged
git branch -D <branch name> deletes branch regardless of if it has been merged
git fetch retrieve all tracking information about the remote repo
git pull <remote name> <branch name> merges the remote branch down to the local branch
git push <remote name> <branch name> merges the local branch up to the remote branch

Reuse

Open Government Licence 3.0