我在我当地的my-feature
分支机构
git status
报告nothing to commit, working tree clean
我想切换到开发分支并在那里做git fetch
(git merge
我更喜欢它git pull
)
但是,这样做会产生以下错误
在这里我首先检查状态,它表明一切都很干净
mymbp:MyProj username$ git status
On branch my-feature
nothing to commit, working tree clean
接下来我尝试检查我的开发分支,这是一个现有的本地分支
On branch my-feature
nothing to commit, working tree clean
mymbp:MyProj username$ git checkout develop
error: Your local changes to the following files would be overwritten by checkout:
MyProj.sln
Please commit your changes or stash them before you switch branches.
Aborting
它抱怨说myProj.sln
已经改变了,即使git status
说什么都没有改变。
再次发出git status
,确认没有任何变化
mymbp:MyProj username$ git status
On branch my-feature
nothing to commit, working tree clean
更新 1
做git ls-files --stage --debug MyProj.sln
如下所示的节目,我看不到任何 4000 或 8000 (--skip-worktree
或--assume-unchanged
标志):
mymbp:MyProj username$ git ls-files --stage --debug MyProj.sln
100644 40c3593ed572beb2139c189455274f8900a1340c 0 MyProj.sln
ctime: 1541703970:521058155
mtime: 1541637062:121492660
dev: 16777220 ino: 8470003
uid: 501 gid: 20
size: 55684 flags: 0
mymbp:MyProj username$
发布git show develop:MyProj.sln
显示解决方案中项目文件的数量及其 GUID,用于前后解决方案的全局部分,但输出很长,仅显示发布、调试配置和一些 GUID。还不知道该怎么办。
更新 2
因此,它看起来好像 MyProj.sln 文件在工作树中,但不在索引和提交(HEAD)中。根据@torek 的解释,发出 git add MyProj.sln 应该将此文件添加到索引中,但事实并非如此,因为没有添加任何内容,并且 git status 在我执行 git add 之前和之后都没有返回任何内容。同时 git checkout 仍然抱怨 MyProj.sln 已更改。git diff 也不返回任何内容
更新 3
我还发现有人建议发出这 2 个命令来获取提交 HEAD 的哈希值,然后查看其中发生了什么变化。我看到很多文件重复,而有些则没有。那些似乎不是我在当前功能分支中添加的文件。那些重复的似乎是来自远程的文件
mymbp:MyProj username$ git rev-parse HEAD
1ca8d8a7c5eff0f2a03eb185f1b25aff27c1d2fd
mymbp:MyProj username$ git ls-tree -r 1ca8d8a7c5eff0f2a03eb185f1b25aff27c1d2fd
这是它的输出
更新 4
我的配置是:
mymbp:MyProj username$ git config --list
credential.helper=osxkeychain
core.excludesfile=/Users/username/.gitignore_global
core.autocrlf=input
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
user.name=User Name
user.email=username@somesystems.com
color.ui=true
color.status.changed=blue normal
color.status.untracked=red normal
color.status.added=magenta normal
color.status.updated=green normal
color.status.branch=yellow normal bold
color.status.header=white normal bold
commit.template=/Users/username/.stCommitMsg
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
remote.origin.url=https://github.com/SomeSystems/MyProj.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.develop.remote=origin
branch.develop.merge=refs/heads/develop
branch.feat-1.remote=origin
branch.feat-1.merge=refs/heads/feat/feat-1
branch.1234-refactoring.remote=origin
branch.1234-refactoring.merge=refs/heads/1234-refactoring
mymbp:MyProj username$