Skip to content

Instantly share code, notes, and snippets.

@JParkinson1991
Created December 11, 2019 09:36
Show Gist options
  • Save JParkinson1991/74d0a95799666effe6b7174cf575947a to your computer and use it in GitHub Desktop.
Save JParkinson1991/74d0a95799666effe6b7174cf575947a to your computer and use it in GitHub Desktop.
GIT Cheetsheet

GIT Cheatsheet

Contents

Interactive Rebase

Useful for altering one or multiple commits. Squashing them into a single commit etc.

git commit rebase -i <commithash>

Example

Commit History: A-B-C-D-E-F where F is HEAD

  • git rebase -i <commithash>
    • Where commit hash is a commit before the commits you want to alter.
    • To change C, and E use <commithash> of B
    • To make changes to A use git rebase -i --root
  • Change the lines for all commits to edit from pick to edit
    • This change is to be made in the editor opened via git.
    • Close it to continue
  • Rebase will then stop at all commits to edit
    • Run required edit command git commit --amend --author="New Guy"
    • Run multiple commands as required
    • Continue rebase with git rebase ---continue
  • After all commits have been edited using the above push to update origin
    • git push -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment