Skip to content

Instantly share code, notes, and snippets.

@bozheville
Last active February 2, 2021 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bozheville/6d26a8454673b978ef0901848cd18923 to your computer and use it in GitHub Desktop.
Save bozheville/6d26a8454673b978ef0901848cd18923 to your computer and use it in GitHub Desktop.
Git cookbook

- Hey mate, looks like I made a typo in my last commit. How can I fix it without another commit?

- Fix a typo and then

git add .
git commit --amend

- Hey mate, I mentioned #24 insted of #42 in my last commit. How can I change it?

- Easily

git commit --amend -m "... #42 ..."

- Hey mate, I addressed a comment from review. Can I just update existing commit? Here's my git log --oneline -4

95d4dd4 (HEAD -> awesome-feature) Remove commented code in A
3cc65e9 Integrage module B
b4a306e Add module B
ac15cf5 Update module A

- 100% Yes

git rebase -i HEAD~4

Then mode the latest commit after the one you want to update with this chane and mark if for fixup

pick ac15cf5 Update module A
f 95d4dd4 Remove commented code in A
pick 3cc65e9 Integrage module B
pick b4a306e Add module B

save. done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment