Reputation:
As you see below, I reverted a commit in local repository and commited but not pushed 2 other changes. But the remote repository still has the commit I reverted. So how can I make the remote repository exactly the local one? (I want to remove that purple branch and push 2 local commits)
The repository is personal, no risk of somebody gets out of sync.
Thanks in advance.
Note: I am a noob at git, so it would be great if you explain your answers clearly.
Upvotes: 1
Views: 44
Reputation: 706
When you have to "delete" a part of history, you have to "force" your push.
But instead of use git push --force
, you'd better use git push --force-with-lease
.
The last command checks whether anyone didn't pushed after the commits you want to destroy. In the case, the push is rejected, avoiding losing your friend's commit(s).
Upvotes: 1
Reputation:
I managed to do this by following command on console:
git push -f
And it basically removed the commit i wanted to remove from remote repository and pushed my local commits.
Upvotes: 1