git: Intermediate Concepts and Commands

Created by: Steve Bass
June, 2019 |

$ git help

$ git help
  • Your new best friend
  • On windows, opens a webpage version of the manual page of the command argument provided
  • Within a proper linux shell environment, prints the man page of the command argument provided

$ git cherry-pick

$ git cherry-pick
  • Cherry picking is simply taking specific commits from git history and applying them onto a different branch
  • Arguments are the SHA-1 hashes associated with the commits desired
  • When multiple hashes are provided, they are applied to the current branch in order of left to right
(master)$ git log
(master)$ git checkout my-branch
(my-branch)$ git cherry-pick 4jfl113n de34123f
(my-branch)$ git log


Cherry Picking: Pros/Cons

  • Specific features can be escalated to other branches
  • New SHA-1 hash codes for each selected commit are applied in the destination branch
  • Its success is heavily dependent on the state of the branch of execution

$ git mergetool

$ git mergetool
  • When downloaded and referenced in a .gitconfig, a merge tool will be invoked
  • Merge tools provide a better merge conflict resolution experience
.gitconfig entries:
  tool = kdiff3
[mergetool "kdiff3"]
  path = /path/to/kdiff3.exe
  keepBackup = false
  trustExitCode = false

Merge Tools

$ git merge

$ git merge
  • When executed on a branch, will merge the argument branch into the currently checked out branch

$ git rebase

$ git rebase
  • Rebasing is exactly what it sounds like 😁
  • Interactive rebasing is a powerful method of keeping history clean
    • Provokes additional review of new commits by original author
    • Allows for squashing (consolidating) commits
(master)$ git pull
(master)$ git checkout my-branch
(my-branch)$ git log
  dj43j5k3  # not yet on master
(my-branch)$ git rebase -i master
# Enter interactive rebase session in text editor to pick/squash/delete dj43j5k3

$ git revert

$ git revert


  • Git commits are created as a git object stored within .git/objects whose contents are hashed into a checksum
  • Reverting backs out the changes of a specific commit
  • Reverting creates a "revert commit"
    • Revert commits can also be reverted, which re-introduces the reverted commit


Deleting Sensitive Data


  • Take a look at the sister-repo: git-intermediate-practice
  • It is pre-configured with branches whose history is set up to allow for practicing the commands covered by this deck. Simply follow the README's instructions to practice!


Be diligent about:

  1. $ git help
  2. Pulling early, and pulling often
  3. Organizing changes into minimal, logical commits
  4. Getting comfortable with merge tools

Helpful Links

  • Atlassian's git cheat sheet - PDF Download
  • Atlassian article on Merging vs. Rebasing, and when each is appropriate
  • The entire Pro Git book by authors Scott Chacon and Ben Straub