当我在本地存储库中的功能分支Feature123
上时,我创建了一个提交,并将其推送到github:
$ git commit -m "Feature123 add unit tests"
[Feature123 53ad59a] Feature123 add unit tests
2 files changed, 94 insertions(+), 2 deletions(-)
$ git push origin Feature123
Counting objects: 10, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (10/10), 1.23 KiB | 0 bytes/s, done.
Total 10 (delta 8), reused 0 (delta 0)
remote: Resolving deltas: 100% (8/8), completed with 8 local objects.
To https://github-repo-url
93f285a..53ad59a Feature123 -> Feature123
在GitHub上,我看到在将功能分支合并到名为master
的分支时存在合并冲突,因此我必须在本地解决冲突。
我先切换到master
然后拉:
$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'
$ git pull
remote: Counting objects: 931, done.
remote: Compressing objects: 100% (307/307), done.
remote: Total 931 (delta 634), reused 473 (delta 471), pack-reused 132
Receiving objects: 100% (931/931), 707.48 KiB | 0 bytes/s, done.
Resolving deltas: 100% (683/683), completed with 329 local objects.
From https://github-repo-url
e30f5fd..64f0158 master -> origin/master
12a9754..ab3ff99 B01312 -> origin/B01312
bbbb9cc..d729e42 B02481_6 -> origin/B02481_6
* [new branch] B02523 -> origin/B02523
550ca90..760be6b B03395 -> origin/B03395
fd54149..2559131 B03616 -> origin/B03616
Updating e30f5fd..64f0158
error: unable to create file dir1/file1: Permission denied
error: unable to create file dir2/file2: Permission denied
Checking out files: 100% (469/469), done.
错误消息"错误:无法创建文件dir1 / file1: 许可被拒绝"意思?
然后我想切换到功能分支,并合并,但
$ git checkout Feature123
error: Your local changes to the following files would be overwritten by checkout:
dir3/file3
dir4/file4
Please commit your changes or stash them before you can switch branches.
Aborting
为什么是
鉴于我已在我的功能分支上提交,master
的工作目录不干净?
我现在该怎么做才能将master合并到我的功能分支中?
答案 0 :(得分:3)
首先,确保git checkout -- .
确实有效。如果您仍然看到" unable to create file... Permission denied
"错误,这通常是为了:
关于第二次结帐,您可以隐藏本地更改,也可以使用git clean -ndx
删除所有内容(删除-n
以进行实际清理)