-1

I have a branch A. In that branch I have done several commits for eg. Commit 5 Commit 4 Commit 3 Commit 2 Commit 1 Where commit 1 is the oldest one. All the commits were pushed successfully and i can even see them in bit bucket. The changes i pushed on commit 3 and commit 4 I can't see those changes in my commit 5. How do i recover that data?

Peace9795
  • 11
  • 6
  • What do you mean by *seeing the changes of commit 3 and 4 in the commit 5*? Can you elaborate? – 0andriy Aug 14 '20 at 18:52
  • I'm guessing, since you are being pretty vague. You changed something in 3 and 4, committed it. Then you changed something in 5, maybe you un-did what you created in 3 and 4? It really matters how you end up here, try to elaborate on that. Generally speaking, you'll see only edits of _a_ commit when inspecting _that_ commit, you'll never see what was done in the past. – Daemon Painter Aug 14 '20 at 20:30
  • My colleague did some changes in commit 3 and 4 and pushed it on git. Then I did a git pull did some changes and pushed it for commit 5. Now the commit 5 doesn't have changes done in 3 and 4. When I click on commit 3 and 4 on bitbucket I'm able to see my colleague's changes but when I click on commit 5, my colleague's changes are missing. – Peace9795 Aug 15 '20 at 03:10

1 Answers1

0

Sounds like your 'commit 5' is not what you intended. You have two possible options.
One:
Use

git revert <commit5-id>

which will create a new commit undoing your 'commit 5'. This is the recommended way forward.

Two:
If you have full permissions on the server, and everyone working on the project understands the consequences and agrees,

git push -f <remote> <commit4-id>:<branch-name>

which will remove 'commit 5' all together.

ianinini
  • 630
  • 6
  • 13