Home > Back-end >  Can I overwrite a remote git commit?
Can I overwrite a remote git commit?

Time:01-27

I committed D' based on B, but some one committed/pushed C on the remote repo. I pushed my D' to the remote repo. But unfortunately I noticed the remote repo merged D with C, and C is not a good commit. But now things are done. could I regret and make the branch commits list as A->B->D->E? By the way, there has no more new commit based on C. enter image description here

CodePudding user response:

I suggest that you do not use --force. A forward fix - rather than changing history - is safe and it's a good solution in almost all cases.

A forward fix could be:

  1. Fix what is broken in the code and commit it. Don't worry about history; just get the code working the way it should. Solved.
  2. In some cases git revert C is enough if you just want to get rid of C.
  • Related