Skip to content

Instantly share code, notes, and snippets.

@vicly
Last active July 3, 2019 02:12
Show Gist options
  • Save vicly/649d0ef2f94c588a8330c9c67d567500 to your computer and use it in GitHub Desktop.
Save vicly/649d0ef2f94c588a8330c9c67d567500 to your computer and use it in GitHub Desktop.
[Git command] #Git
# refresh local branches with remote
git remote update origin --prune

Modify last commit message

# Replace last commit with new
git commit --amend
git commit --amend -m "the updated message"

Add more changes to last commit

You create a commit "A", and then modified files. Now you want a single commit including "A" changes and these new changes.

# add modified files into staging
git add .
# auto amend last commit and replace it with a new one
git commit --amend --no-edit

Merge latest N commit into one

# assume N = 2
git rebase -i HEAD~2

# mark 1st as "r", the else as "s"
# modify the commit message, then :wq!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment