Links

ΜΆ
Adam I. Gerard
TBD
TBD
TBD

Git Cheat Sheet

Some common and useful Git commands.

View Branch Commit History

  1. git log

View Entire Local Change History

  1. git reflog

View File Changes

By SHA:

  1. git diff --name-only af43c41d..HEAD
  2. git diff af43c41d..master

By branch:

  1. git diff --name-only origin/deploy..master
  2. git diff origin/deploy..master

Correct Previous Commits

Review, alter, remove, amend last 3 commits:

  1. git rebase -i HEAD~3
  2. Type i to enter interactive mode.
  3. Find the line with the desired commit hash. Modify it using pick, drop, etc.
  4. Hit the esc button to exit interactive mode.
  5. Type wq to save and close the file (Git will proceed through the stipulated changes) or type q! to close the file abandoning all changes.
  6. git push -f to override previous changes - do not use this on master/main only ever within a development branch.

Git Amend

Correct the last commit message:

  1. git commit --amend -m "Your new message"

Discard Uncommitted Branch Charge

  1. git clean -f -d
  2. git reset --hard HEAD

Abandon a Rebase

  1. git rebase --abort
  2. git clean -f -d
  3. git reset --hard HEAD
  1. https://devhints.io/vim
  2. https://git-scm.com/doc

Contents