can't merge master branch to gh-pages

2019-08-06 13:38发布

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?

2条回答
欢心
2楼-- · 2019-08-06 14:02

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

查看更多
霸刀☆藐视天下
3楼-- · 2019-08-06 14:11

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.

查看更多
登录 后发表回答