Short-hand Series: Git

Git is a distributed version control system for managing files. It is extremely suitable for managing versions of text documents. Git repository may be managed using CLI and GUI tools. These GUI tools mostly come bundled with the CLI and abstract the command to manage the repository through buttons and text fields. It is rather important to be familiar with the command line way of managing your repository for the edge case when GUI isn’t unavailable

Common Commands for managing Git

a) git init : prepare a directory to be a git repo

b) git status : show the current state of the repo and files

c) git add [file_name/directory] : add the file/directory to the git repo. Changes made to this file/directory shall be monitored by git

d) git commit -m “message” : add the changes made to the local copy of the repo.

e) git log : show the commits that have been made to the repo

f) git remote add [url] : sets up the local copy to use the server at [url] as remote copy. This allows for collaborations as contributors can access the copy of the repo to work on and send changes

g) git pull [origin -u branch_name] : sync the local copy with the server. Optional: specify the branch to update

h) git diff : shows the changes between the files on the remote and local copy

i) git reset <commit_id> : update the local copy to the exact commit

j) git checkout [branch_name] : make the branch active

k) git rm [file_name/dir(s)] : remove file(s)/dir(s) from the git log

l) git merge [branch_name] : combine branch_name with the active branch

m) git branch -d [branch_name] : delete the branch from git

n) git push [origin -u branch_name] : send changes to the server

o) git amend : edit the latest commit