-2

I made changes in my project, then did git reset --hard HEAD, but I notice that some of the changes are still present. When I run git status I get Your branch is behind '<my branch>' by 1 commit, and can be fast-forwarded.

Can anyone explain this message, and advise me on how to approach it so that I can undo all the changes that I made after my previous commit?

gkeenley
  • 6,088
  • 8
  • 54
  • 129
  • There's nothing wrong so what's the problem? Don't worry, be happy. – matt May 12 '22 at 12:15
  • It means the remote has one additional commit after the one your local repository has. Is that commit, on the remote, part of the "changes that you made after your previous commit"? Meaning, do you want to get rid of that commit? – Lasse V. Karlsen May 12 '22 at 12:18
  • @LasseV.Karlsen Yes, now that I check it there is one commit on the remote that I don't see on my local. So yes, that commit is part of the "changes I made after previous commit", and I'd like to get rid of them. – gkeenley May 12 '22 at 12:26
  • Then you can probably get away with the force push that Piotr has written about in his answer. – Lasse V. Karlsen May 12 '22 at 12:28

1 Answers1

1

In order to go back one commit and overwrite the remote, you can

git push --force

Provided that you are happy with the state of your repository on your local machine. Otherwise, just git pull to fast-forward.

Piotr Ostrowski
  • 520
  • 5
  • 8