"Git Pull Force", "git reset branch to origin" or in other words, to pull a remote branch to overwrite a local branch, seems to be wildly searched feature with an increasing interest despite few local declines.
And it absolutely makes sense with growing teams and ever increasing number of developers.
Currently, the shortest working solution is quite verbose and requires knowledge of the branch
git reset --hard origin/<branch_name>
edit: There is a more convenient variant
git reset --hard @{u}
.
Please give credit where it is due comment. More shortcuts here.
which is unfortunate, as typing the following is so much faster
git pull
which, however, brings its own challenges. Diverging histories, merge conflicts, etc...
We do have shorthands such as this
git push origin HEAD -u --force
which pushes a local branch <branch_name>
to an origin, overwrites a remote branch with same name <branch_name>
and sets it as it's own upstream branch.
However, there is no such --force
/reset
alternative to git pull
.
What would be the best way to have this feature added to git?
How do I force "git pull" to overwrite local files? 6.6m views
Reset local repository branch to be just like remote repository HEAD 4.7m views
How do I force git pull to overwrite everything on every pull? 370k views
Resolve conflicts using remote changes when pulling from Git remote 240k views
How to force update when doing git pull? 90k views
Force GIT Pull without commiting
Force a pull with git
git force pull with implicit rebase
Clean up a fork and restart it from the upstream
Force git to update my local repo when pulling
Reset all branches of a local repo to be the same as remote
Github - Discard all changes