mirror of https://github.com/zulip/zulip.git
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
pick
toreword
, and save - Change the commit messages
Deleting old commits
git rebase -i HEAD~n
wheren
is the number of commits you are looking at- For each commit that you want to delete, change
pick
todrop
, and save
Squashing commits
Sometimes, you want to make one commit out of a bunch of commits. To do this,
git rebase -i HEAD~n
wheren
is the number of commits you are interested in- Change
pick
tosquash
on the lines containing the commits you want to squash and save
Reordering commits
git rebase -i HEAD~n
wheren
is 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.)