can't merge master branch to gh-pages

南笙酒味 提交于 2020-01-05 09:28:31

问题


I have checked out gh-pages branch. I try git merge master and I receive the following "error: The following untracked working tree files would be overwritten by merge: ... Please move or remove them before you can merge." That's exactly what I want to do. I want the files on the master branch to override the versions of those same files on the gh-pages branch. I have read up a little on versions of the git rm... command and also tried git stash and git reset head. I still get the same error.

In short, how do I ignore the current status of gh-pages and overwrite them with master branch?


回答1:


If you don't want to keep the current untracked files in your working tree for gh-pages then you could blast them away and perform the merge:

git reset --hard
git merge master

If you do want to keep those files you can add then commit them, and then do the git merge master




回答2:


You have some untracked files on your current branch that are versioned on master branch. Merging master (or checking out master) would overwrite them without the possibility to reverse that. Git always tries to prevent you from loosing data that cannot be restored until you explicitly told it to do so. Here are the things you can do:

  1. git clean -f (but first run --dry-run to see if you don't delete something you actually don't want to remove)
  2. Delete listed files using rm (not git rm)
  3. git stash -u
  4. add untracked files, commit them and then merge.

and probably many other things to get rid of them.



来源:https://stackoverflow.com/questions/23572280/cant-merge-master-branch-to-gh-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!