![]() # interactive rebase in progress onto b057371 Save&quit will see the edit page similar to method #1:.If no noop issue, then simply change the word pick to reword, other just remains (you don't edit commit message at this point), e.g:.if you do git rebase -i 881129d771219cfa29e6f6c2205851a2994a88 which missing ^ at the end, you better quit the editor without save and figure out the reason: But if you see noop then you are probably typing wrong, e.g.# Note that empty commits are commented out # However, if you remove everything, the rebase will be aborted. # If you remove a line here THAT COMMIT WILL BE LOST. # These lines can be re-ordered they are executed from top to bottom. # x, exec = run command (the rest of the line) using shell # f, fixup = like "squash", but discard this commit's log message # s, squash = use commit, but meld into previous commit # e, edit = use commit, but stop for amending # r, reword = use commit, but edit the commit message Then you can do git rebase -interactive 881129d771219cfa29e6f6c2205851a2994a8835 or git rebase -i HEAD^ (if the latest) You can see the commit hash by git log or extract from the Then do git push -u origin master -force or -force.# Please enter the commit message for your changes. As you can see, commit message on top without any prefix of command such as pick, this is already the edit page and you can direct edit the top message and save&quit, e.g.:.# On branch is up to date with 'origin/master'. # with # will be ignored, and an empty message aborts the commit. # Please enter the commit message fir your changes. If you only want to edit latest commit message, then you only need git commit -amend, you would see:.THis commit is provided only to document a correction to a previous commit message. This commit has no substantive code change. ![]() In the future, if you need to search through a git log for a feature keyword, the original (erroneous) commit may not appear because the wrong keyword was used in that original commit (the original typo) - however, the keyword will appear in the errata commit which will then point you to the original commit that had the typo. This type of thing so rarely happens that simply documenting the mistake is good enough. ![]() It's certainly easier and safer than rebasing, it doesn't modify true history, and it keeps the branch tree clean (using amend is also a good choice if you are correcting the most recent commit, but an errata commit may be a good choice for older commits). An errata commit is a commit with no substantive code changes but an important commit message - for example, add one space character to your readme file and commit that change with the important commit message, or use the git option -allow-empty. It also provides an incredible tree view of commit parentage, perfect for when you need to instantly understand what happened with this weird merge/rebase that broke things, and to screenshare it to teach colleagues who might not have developed an internal understanding of the tree structure that Git is based on.Another option is to create an additional "errata commit" (and push) which references the commit object that contains the error - the new errata commit also provides the correction. ![]() You can swipe over a bunch of lines or let the software identify a whole span of contiguous changed lines, click a button, and see just those changes move over from your unstaged to staged changes, then commit exactly what you want.Ī lot of times people don't even understand how powerful the staging area is they're just used to saying git add & git commit without realizing that it can be an incredible way to take a day of chaotic fixes and turn it into a set of commits you can be proud of! For those who want a GUI around this on Mac, is an incredible secret weapon. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |