Can I tell git pull to overwrite instead of merge?

ε祈祈猫儿з 提交于 2019-11-28 20:18:11

First, rename your master branch to something else:

git branch -m master my_old_master

Then, create a new master:

git checkout -b master someRemote

The great thing about Git's branch names is that they aren't actual places themselves, they're just pointers to places (where a "place" is a SHA1 commit id).

Sounds like you're after git checkout, which will discard your local changes to a path.

You can revert your changes using checkout:

git checkout myfile.h

will restore myfile.h from the index

http://git-scm.com/docs/git-checkout

VonC

If you want to keep your current master branch but register a new version (mirroring the remote branch), you can;

  • register a merge filter driver (just for this merge: a keepTheir one)
  • do a git pull --no-commit
  • check if there aren't extra files that need to be removed (files in your master that were not present in the remote branch)
  • commit
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!