0

The code is correct. The problem is that accidentally, I pushed a commit with the wrong comment. Now I need a commit simply to say that the previous commit has the wrong description so that when other programmers in the future read it in the thread, they can see that instead of getting confused about what was going on with what I did in the code. Again, code is good, comment is wrong. Thanks.

UPDATE 1:

The problem is that in local I see this:

C:\[path]\app>git log -1
commit 4b95d595812211553080046bf3abd504c0862cea
Author: Jaime Montoya <[email protected]>
Date:   Wed May 2 16:49:34 2018 -0600

    Use [bla bla bla] picture so that the picture can be found correctly even when [bla bla bla].

C:\[path]\app>

But in remotes I see this:

C:\[path]\app>git log -1 remotes/origin/[branch name]
commit 8bf85f6a0f3ba136ebcf1cad76fcff15775296c1
Author: Jaime Montoya <[email protected]>
Date:   Mon May 7 09:58:29 2018 -0600

    Remove code that generates [bla bla bla]

C:\[path]\app>

What I see in remotes/origin/[branch name] does not match what I see in my local [branch name].

UPDATE 2:

Basically I did a git reset --hard [commit] and then pushed to my public repository remotes/origin/[branch name]. To my surprise, the message in the latest commit in the public repository did not match the message of the commit I had gone back to in my localhost when I used git reset --hard [commit]. That was the reason why I wanted to modify the message of the commit in the public repository, but I see that that message does not even match what I have in my localhost. I wonder why.

5
  • did you already push it to the remote? Commented May 7, 2018 at 16:38
  • 1
    You can just change the commit message instead of adding unnecessary additional commits. Commented May 7, 2018 at 16:39
  • 1
    Just use --amend to fix the comment, then push -f if necessary. Commented May 7, 2018 at 16:39
  • @DanielA.White Yes, I did already push it to remote. Commented May 7, 2018 at 16:58
  • If you did not use one of the various forcing options, your git push of the "amended" (really, copied) commit will have failed. Use --force-with-lease if available, and remember the usual caveats about replacing published commits. Commented May 7, 2018 at 17:23

1 Answer 1

1

That's when you use git commit --amend. Look at the docs:

Changing your most recent commit is probably the most common rewriting of history that you’ll do. You’ll often want to do two basic things to your last commit: simply change the commit message, or change the actual content of the commit by adding, removing and modifying files.

If you simply want to modify your last commit message, that’s easy:

$ git commit --amend
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.