Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to overwrite with a git push, overwrite changes to the git server?

Tags:

We are pushing builds to heroku and would like to push without pulling in latest changes. I am essentially using the github repo as my source control repository and pushing to the git heroku repo from several different machines. Since we have a few build servers pushing to the same heroku repository sometimes a push of latest bits from a build server will throw a message saying I need to pull latest before committing and pushing.

However since the code from the build server is guaranteed to be the latest, I'd like to throw away the changes from the pull and just commit and push the files without a merge.

Is there a way to do this? Any other suggestions on how best to set this up?

like image 477
MonkeyBonkey Avatar asked Jan 17 '12 04:01

MonkeyBonkey


People also ask

Does git push overwrite?

Git prevents you from overwriting the central repository's history by refusing push requests when they result in a non-fast-forward merge. So, if the remote history has diverged from your history, you need to pull the remote branch and merge it into your local one, then try pushing again.

How do I override local changes in git?

Just like git push --force allows overwriting remote branches, git fetch --force (or git pull --force ) allows overwriting local branches.


1 Answers

Just do git push -f ( force push )

Pushing to heroku might be one of the valid use cases for git push -f, but still be careful and understand what you are doing.

like image 83
manojlds Avatar answered Oct 28 '22 18:10

manojlds