![]() # You are currently editing a commit while rebasing branch 'master' on '4dc005b'.Ĭorrecting the spelling to "Added stylesheet", then save and exit the editor. # Next command to do (1 remaining command): # interactive rebase in progress onto 4dc005b A new editor will open with the contents: Added stilesheet We want to perform the "reword" command on the 468d547 commit, so change the contents to: reword 468d547 Added stilesheet # Rebase 4dc005b.3ebd64d onto 4dc005b (2 commands) This will again open your CLI editor ( $EDITOR), with the truncated contents: pick 468d547 Added stilesheet To fix the spelling mistake in the middle commit, we need to use the " interactive rebase " command, looking back 2 commits: git rebase -i HEAD~2 This will rewrite the commit, as evidenced by the different commit hash: $ git log -onelineģebd64d (HEAD -> master) Added JavaScriptīecause the remote repository doesn't know about this commit yet, we don't need to do any additional work. Change the commit message to "Added JavaScript", then save and exit the editor. We didn't update the stylesheet in this commit, we added some JavaScript. # (use "git push" to publish your local commits) # Your branch is ahead of 'origin/master' by 2 commits. # with '#' will be ignored, and an empty message aborts the commit. # Please enter the commit message for your changes. This will open your CLI editor ( $EDITOR) with the contents: Updated stylesheet To fix the incorrect message in the most recent commit we can use the "amend commit" command: git commit -amend Scenario 1: changing the most recent commit The first commit has a misspelling, and it is pushed.The middle commit has a misspelling, and it is not pushed.The last commit has an incorrect message, and it is not pushed. ![]() There are three scenarios to correct here: īd9d97a (HEAD -> master) Updated stylesheet $ echo "console.log('debug') " > script.js & git add. Aded homepageġ file changed, 0 insertions(+), 0 deletions(-) ![]() Starting from an empty repository that was freshly cloned, let's create an example situation with a few commit message mistakes: $ touch index.html & git add. The Git commands to change a commit message are situational - here's a short guide to all of them. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |