Abstract


  • The modern tool used to empower developers to collaborate
  • Great for disaster recovery, allows us to roll back to a particular point seamlessly
Command Cheatsheet
# Making a new Git branch
git branch <NEW_BRANCH_NAME> 
 
# Delete local branch
git branch -d <branch-name>
# Delete remote branch
git push origin --delete <branch-name>
 
# Hard Reset
# Use this caution, make sure other collaborators are not working on any commits after the <COMMIT_ID>
git reset --hard <COMMIT_ID>
 
# Merge feature branch changes
# On main branch
git merge <FEATURE_BRANCH>

Move local commits from branch A to branch B

  • Merge commits into branch B
  • Delete local branch A, or Git Rebase for more refine control

Git Add-ons


  • A list of small tools that extend on Git

git-open

  • Type git open to open the repo website (GitHub, GitLab, Bitbucket) in your browser
  • Install with Basher - basher install paulirish/git-open

git-quick-stats

  • Access various useful statistics in a git repository
  • Install with Basher - basher install arzzen/git-quick-stats

Github


Setup a Private Email in Git with Github

Terminologies


Remote

  • The Repo in a central cloud
  • Default name is origin

Local

History

Force Push

  • A command git push --force <remote> <branch> that overwrites the Remote repository’s history with the Local repository’s history