Skip to content


Is a Distributed version control system used in Software development

Commit - snapshot A good example of a standard fork/change/PR workflow


git init - initialize directory with git

Staging Area

git add <file> <file> - add file to index
git add . - add all files
git status - list modifications
git rm file.txt - remove a file


git commit -m "message" - commit
git log - See all commit
git checkout master or <commit-hash> - Go back to the latest or specified commit
git reset HEAD -- <file or folder> - Remove a file/folder from staging area


Some projects require a sign-off, which add Signed-off-by: NAME <[email protected]> in the comment.


git branch - list all branch
git branch <new-branch-name> - create new branch
git checkout <branch-name> or master - switch to branch-name / master
git merge <branch-name> - merge branch-name into current branch
git branch -d <branch-name> - delete a branch



git remote add REPO https://URL - add remote repo
git remote remove REPO - remove repo
git remote -v - check connected git


git clone - copy the latest repo from remote
git push - push to remote
git pull - pull latest from remote


Is a file to manage what should be in git and what not

# Ignore few files and folder

# Ignore everything

# But not the pub folder and up to 2th subfolder level

Partial sync - Sparse checkout

  • Download only a part of a repository - Source sh # Clone the repo without content git clone -n --depth=1 --filter=tree:0 cd test-git-partial-clone-big-small-no-bigtree # Select two dirs to keep: small and small2 git sparse-checkout set --no-cone small small2 # Download everything git checkout
  • Ignore changes tracking on existing file like .gitignore (source): git update-index --assume-unchanged .gitignore