[英]git - Switching to a local develop, then back to feature branch resets the status of modified/added files
I added some changes in my feature branch, staged, committed and pushed it to origin using push -u git command.我在我的功能分支中添加了一些更改,使用 push -u git 命令暂存、提交并推送到原点。
Next day, I updated my local develop and feature branches to get latest code from remote using standard git fetch / git merge procedures.第二天,我更新了我的本地开发和功能分支,以使用标准的 git fetch / git merge 程序从远程获取最新代码。
At this point, I am seeing some interesting things:在这一点上,我看到了一些有趣的事情:
I am on my feature branch, git status
tells me all is clean, this is correct我在我的功能分支上, git status
告诉我一切正常,这是正确的
I switch to develop branch, git status
shows all is clean, this is correct我切换到开发分支, git status
显示一切正常,这是正确的
I switch back to my feature branch, git status
reports all my changes that I already pushed to remote day before as follows:我切换回我的功能分支, git status
报告了我之前已经推送到远程一天的所有更改,如下所示:
I dont understand why is this happening but it should not.我不明白为什么会发生这种情况,但不应该。
If I issue git add .
如果我发出git add .
, no message shows in git, I am just back to the terminal command. , git 中没有显示任何消息,我只是回到终端命令。
If I issue now git status
, it now shows that my feature branch is uptodate "nothing to commit, working tree is clean".如果我现在发出git status
,它现在显示我的功能分支是最新的“没有任何提交,工作树是干净的”。
Switching back and forth from feature to develop and develop to feature branches like described above on my Mac reproduces same problem over and over.在我的 Mac 上从功能来回切换到开发和开发到功能分支,一遍又一遍地重现相同的问题。 Doing so on my Windows machine is not reproducing this issue at all.在我的 Windows 机器上这样做根本不会重现这个问题。
So, my conclusion is that something is wrong with my git environment on my Mac machine .所以,我的结论是我的 Mac 机器上的 git 环境有问题。
But then, I also tried getting a brand new clone of my project on my Mac (which now contains my feature branch since I pushed it with all my changes using git push -u command), then tried switching back and forth on that clone between develop and my feature branch and the issue was NOT happening.但是,我还尝试在我的 Mac 上获取我的项目的全新克隆(它现在包含我的功能分支,因为我使用 git push -u 命令推送了所有更改),然后尝试在该克隆之间来回切换开发和我的功能分支,但问题没有发生。 That made it even more confusing.这让事情变得更加扑朔迷离。
It looks like something is not being updated properly with my git on my Mac machine.看起来我的 Mac 机器上的 git 没有正确更新某些内容。 What could it be and how to investigate this?这可能是什么以及如何调查?
We are crossplatform team working on both Mac and Windows.我们是在 Mac 和 Windows 上工作的跨平台团队。 My core.autocrlf
is set to input
on my Mac and to true
on my Windows.我的core.autocrlf
设置为在 Mac 上input
,在 Windows 上设置为true
。 I dont know other team members settings for core.autocrlf
.我不知道core.autocrlf
其他团队成员设置。
First, make sure git config core.autocrlf
is always set to false (on Windows or Mac).首先,确保git config core.autocrlf
始终设置为 false(在 Windows 或 Mac 上)。
Any EOL conversion you might need should be done in a .gitattributes
eol
attribute .您可能需要的任何 EOL 转换都应该在.gitattributes
eol
属性中完成。
Then check your git config -l
in your repo on the two platform: a content filter driver could be an example of automatic modification on commit, which might not be declared on the other platform.然后在两个平台上检查您的 repo 中的git config -l
:内容过滤器驱动程序可能是提交时自动修改的示例,可能不会在其他平台上声明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.