mirror of
https://github.com/zulip/zulip.git
synced 2025-10-24 08:33:43 +00:00
1.4 KiB
1.4 KiB
Fixing Commits
This is mostly from here.
Fixing the last commit
Changing the last commit message
git commit --amend -m "New Message"
Changing the last commit
- Make your changes to the files
- Run
git add <filename>to add one file orgit add <filename1> <filename2> ...to add multiple files git commit --amend
Fixing older commits
Changing commit messages
git rebase -i HEAD~5(if, for example, you are editing some of the last five commits)- For each commit that you want to change the message, change
picktoreword, and save - Change the commit messages
Deleting old commits
git rebase -i HEAD~nwherenis the number of commits you are looking at- For each commit that you want to delete, change
picktodrop, and save
Squashing commits
Sometimes, you want to make one commit out of a bunch of commits. To do this,
git rebase -i HEAD~nwherenis the number of commits you are interested in- Change
picktosquashon the lines containing the commits you want to squash and save
Reordering commits
git rebase -i HEAD~nwherenis the number of commits you are interested in- Reorder the lines containing the commits and save
Pushing commits after tidying them
git push origin +my-feature-branch(Note the+there and substitute your actual branch name.)