user892134
user892134

Reputation: 3214

Git push to remote repo , force overwrite

Before I do this just want some clarification:

git push -f origin develop

This will overwrite the branch on my remote repo called develop.

Will I be able to revert back to the previous commit on remote repo after doing this?

Upvotes: 0

Views: 2850

Answers (1)

Seth
Seth

Reputation: 338

Possibly not. You may lose some of your history.

If you have rewritten the history of your local repo such that the previous commit is gone, then once you force push those changes to the server you will not be able to get it back. Performing a force push makes the server copy match your local copy exactly, including any modifications to history.

If your goal isn't to rewrite history, I would recommend the following steps:

  1. Do a git pull to merge your remote repository with the remote repository. You will probably have merge conflicts.

  2. Resolve the merge conflicts by hand.

  3. Commit your resolution of the merge conflicts.

  4. Do a normal push once the merge conflicts are resolved.

Upvotes: 3

Related Questions