问题
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:
- git clean -f (but first run --dry-run to see if you don't delete something you actually don't want to remove)
- Delete listed files using rm (not git rm)
- git stash -u
- 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