Skip to content

Instantly share code, notes, and snippets.

@mislav mislav/
Last active May 20, 2020

What would you like to do?
git merge, reset, rebase, checkout

What I believe is the most confusing thing for git beginners is that the main commands have multiple uses depending on the arguments or context, and some of those uses aren't well-described by the command's name.


  • merges together different branches (different histories, to be more exact)
  • fast-forwards if a merge isn't necessary; effectively repositioning the branch head to a descendant commit
  • unwanted outcome of git pull


  • replays a set of commits as if they were based off another parent
  • interactively used for history cleanup: reorder & squash related commits
  • should be used for git pull instead of merge


  • resets (unstages) changes added to the index; undoes git add
  • repositions the branch head to another commit; optionally resetting index & working tree
    • undo a commit, either discarding changes or keeping them for the next commit
    • discard all working copy changes since the last commit


  • switch branches
    • create a new branch and switch to it
  • checkout a file or directory as it were in another commit
    • discard all working copy changes since the last commit
    • resolve merge conflicts

This comment has been minimized.

Copy link

Raz240 commented Feb 27, 2018

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.