在Ubuntu和Debian下,最后提交的文件正在设置执行位,之后我尝试结账。这很奇怪,让我疯了:
$ ls -l file
-rw-r--r-- ... file
# on branch master:
$ git commit -m 'mode is 644' file
[master 0123456] mode is 644
1 files changed, 1 insertions(+), 1 deletions(-)
# All ok
$ git checkout dev-branch
Switched to branch 'dev-branch'
# Seemingly all ok, but file now has the exec bit set
$ git merge master
Updating 6543210..0123456
error: Your local changes to 'file' would be overwritten by merge. Aborting.
Please, commit your changes or stash them before you can merge.
# Oops...
$ ls -l file
-rwxr-xr-x ... file
有没有人知道,执行位何时以及为什么会滑入? core.filemode
被设置为 true
。
我在分支切换期间在vim中打开文件,如果这在某种程度上是重要的。
附录1: 这是结帐,权限被搞砸了。我可以继续玩游戏:
$ git br
* master
dev-branch
$ git diff
diff --git a/file b/file
old mode 100644
new mode 100755
$ chmod 644 file
$ git diff
$ git checkout dev-branch
$ git diff
diff --git a/file b/file
old mode 100644
new mode 100755
$ chmod 644 file
$ git diff
$ git checkout master
$ git diff
diff --git a/file b/file
old mode 100644
new mode 100755
# ...and so on ad inf.
附录2: 顺便说一下,对于我提交的存储库中的每个文件,都会发生这种情况。成功提交后,我无法在没有权限搞砸的情况下切换分支。
git-log
根本没有显示任何输出 master
, dev-branch
要么 HEAD
(这很奇怪,不是吗?命令不应该打印最后一次提交消息 master
?)