Computer Science Mojo

~ David's Notes on coding, software and computer science




Post

Git Cheatsheet

Category: Git     Tag: Git   Web  
By: David     On: Sun 28 July 2019     

Some Git commands

Shorthands

  • HEAD Latest commit
  • HEAD^ OR HEAD~1 commit before latest commit

Branching

  • git mergetool use the installed mergetool to resolve conflicts
  • git cherry-pick -n HASH checrry-pick a single commit -n prevents it auto adding a commit

History

  • git log --oneline gives a one log history

Diff

Revert

  • git revert -n HEAD revert the last commit - always revert backwards

Reset

  • git reset --hard HEAD

Tagging

  • git tag

Submodules

  • git submodule add GITURL REPO
  • git submodule init REPO
  • git submodule update REPO

Reflog

  • git reflog

Bisect

bisects the commit to find where the bug was addeded in

  • git bisect start
  • git bisect bad
  • git bisect good