![]() ![]() (Using the -o ( -only) flag to make sure you change only the commit message) If it's your last commit, just amend the commit: git commit -amend -o -m "New commit message" Note: You can also "Make the change you want" from the editor opened by git commit -amend Make the change you want to commit and then run git commit -amend Mark the first commit (the one that you want to change) as “edit” instead of “pick”, then save and exit your editor. (Replace commit_count with number of commits that you want to edit.) This command launches your editor. If you want to edit more than one commit message, run git rebase -i HEAD~ commit_count To fix the previous commit by removing it entirely, run git reset -hard HEAD^ To amend the previous commit and keep the same log message, run git commit -amend -C HEAD Change the commit message as you want, then save the file and quit your editor to finish. It starts out populated with the text from your old commit message. This will open a file in your text editor representing your new commit message. To amend the previous commit, make the changes you want and stage those changes, and then run git commit -amend How do I recover/resynchronise after someone pushes a rebase or a reset to a published branch? Or maybe you do, but in that case you will have to take great care to communicate with everyone who may have pulled your commits and done work on top of them. Note that you will not want to change commits that you have already pushed. It’s very easy you don’t need to memorise it – just remember that git rebase -interactive lets you correct commits no matter how long ago they were. Most of this sequence will be explained to you by the output of the various commands as you go. For each commit you want to edit, Git drops you into the shell.
0 Comments
Leave a Reply. |