0

I am working on a project where I had made a few changes, committed it and pushed it, however later, I forgot about these changes, soft reset these changes and put them with my next commit, is there anyway I can recover the old commit without affecting the new changes I made? Thanks.

1
  • "is there anyway I can recover the old commit" Certainly. You pushed it, so it's on the remote and in your remote tracking branch. And it's in the reflog. I'm a little unclear what you want to do with it, or what "without affecting the new changes I made" means, but it is easily recovered. Commented Mar 3, 2022 at 3:40

1 Answer 1

1

Tell me if I got it right. You are on branch X, developed something, committed, then pushed. Then you did a git reset --soft HEAD~, worked some more and committed again, so you have the previous work with some more work in a single revision that diverged from the revision you already pushed into the remote. Now, you would like to get this revision kind of on top of the first revision you committed/pushed?

git reset --soft origin/X
git commit -m "only the changes from second revision"

Adjust the name of the remote branch and it should work.

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.