简体   繁体   English

git - 切换到本地开发,然后返回功能分支重置修改/添加文件的状态

[英]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报告了我之前已经推送到远程一天的所有更改,如下所示:

  1. STAGED (GREEN) - My changed are being removed (which marks some files as being ready to commit).暂存(绿色) - 我的更改正在被删除(这将某些文件标记为已准备好提交)。 The existing files are marked as modified and my changes are removed from them.现有文件被标记为已修改,我的更改将从其中删除。 The files I added are marked as deleted,我添加的文件被标记为已删除,
  2. NOT STAGED (PURPLE) - The existing project files I modified as part of my push,未上演(紫色) - 我在推送过程中修改的现有项目文件,
  3. UNTRACKED (RED) - The new files I added to the project as part of my push above. UNTRACKED (RED) - 我添加到项目中的新文件作为我上面推送的一部分。

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.

相关问题 git pull 添加了大量未跟踪的文件和修改过的文件 - git pull added tons of untracked files and modified files 保持要素分支与“ develop”分支同步的别名 - Alias for keeping feature branch in sync with “develop” branch 如何更改git status的行为,显示最终未提交的已修改文件? - How to change the behavior of git status showing modified files which are eventually not committed? git stash离开修改过的文件? - git stash leaving modified files? 实时Windows Server上的Git-尝试从存储库中提取但本地文件已被修改 - Git on live Windows Server - Trying to pull from the repo but local files already modified SVN在Windows中导出最新的修改/添加的文件 - SVN Export latest modified/added files in Windows GIT预提交钩子,在修改/添加的文件中搜索非UTF-8编码(如果发现任何文件,则拒绝提交) - GIT pre-commit hook which searches non-UTF-8 encodings among modified/added files (and rejects commit if it finds any) 如何从git导出所有分支更改的文件与本地主文件相比 - how to export all branch changed files compared to local master from git git如何在Windows上检测修改的文件? - How does git detect modified files on Windows? 在git中更改分支会导致修改文件 - Changing branches in git mistakenly results in modified files
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM