Reputation: 29
All previous commitments except one commit were initialized by another team member by force pushing, even though the phrase "data could be lost" appeared.
There's only one commit(last one) on the git log. Can't I go back to before the team member made a mistake?
I didn't think it would work, but I've tried git reset --HEAD^
and I got
fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]'
Upvotes: 0
Views: 34
Reputation: 182000
After a force push, other team members couldn't simply have done git pull
, so someone likely still has a recent copy of that branch. Simply force push that one to the server.
If everyone has somehow already pulled the broken branch, you can still get the hash of the original by using git reflog
(until a git gc
is triggered). Grab the hash of the commit that should become the new HEAD
, then do:
git reset --hard <name of branch> <hash of desired commit>
And then go configure your git server to forbid force pushing ;)
Upvotes: 3