git-切换到本地开发,然后返回功能分支以重置已修改/已添加文件的状态 [英] git - Switching to a local develop, then back to feature branch resets the status of modified/added files

查看:266
本文介绍了git-切换到本地开发,然后返回功能分支以重置已修改/已添加文件的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在功能分支中添加了一些更改,进行了暂存,提交并使用push -u git命令将其推送到了原点.

I added some changes in my feature branch, staged, committed and pushed it to origin using push -u git command.

第二天,我更新了本地开发和功能分支,以使用标准git fetch/git merge程序从远程获取最新代码.

Next day, I updated my local develop and feature branches to get latest code from remote using standard git fetch / git merge procedures.

在这一点上,我看到了一些有趣的东西:

At this point, I am seeing some interesting things:

我在功能分支上,git status告诉我一切都很好,这是正确的

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:

  1. 已暂存(绿色)-我的更改已被删除(将某些文件标记为可以提交).现有文件被标记为已修改,并且我的更改从其中删除.我添加的文件被标记为已删除,
  2. 没有暂存(紫色)-我在推送过程中修改了现有项目文件,
  3. 未跟踪(红色)-作为我在上面的推送操作的一部分,我将新文件添加到了项目中.
  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.

我不明白为什么会这样,但是应该不会.

I dont understand why is this happening but it should not.

如果发出git add .,则git中没有消息,我只是返回到终端命令.

If I issue git add ., no message shows in git, I am just back to the terminal command.

如果我现在发布git status,它现在表明我的功能分支是最新的,什么也没提交,工作树很干净".

If I issue now git status, it now shows that my feature branch is uptodate "nothing to commit, working tree is clean".

在我的Mac上,从功能切换到开发,再开发到功能分支,就像上面所述的那样,一遍又一遍地重现同样的问题.在我的Windows计算机上执行此操作根本不会重现此问题.

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. Doing so on my Windows machine is not reproducing this issue at all.

因此,我的结论是我的Mac机器上的git环境出现了问题.

但是,然后,我也尝试在Mac上获得项目的全新克隆(由于我使用git push -u命令将所有更改都推送了该分支,所以现在包含了我的功能分支),然后尝试来回切换在develop和我的功能分支之间克隆的那个问题没有发生.这使它更加混乱.

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. That made it even more confusing.

我的Mac机器上的git似乎未正确更新某些内容.可能是什么以及如何对此进行调查?

It looks like something is not being updated properly with my git on my Mac machine. What could it be and how to investigate this?

我们是跨平台的团队,致力于Mac和Windows.我的core.autocrlf在Mac上设置为input,在Windows上设置为true.我不知道core.autocrlf的其他团队成员设置.

We are crossplatform team working on both Mac and Windows. My core.autocrlf is set to input on my Mac and to true on my Windows. I dont know other team members settings for core.autocrlf.

推荐答案

首先,确保git config core.autocrlf总是 设置为false(在Windows或Mac上).
您可能需要的任何EOL转换都应在 .gitattributes eol属性中完成

First, make sure git config core.autocrlf is always set to false (on Windows or Mac).
Any EOL conversion you might need should be done in a .gitattributes eol attribute.

然后在两个平台上的仓库中检查您的git config -l:内容过滤器驱动器可能是在提交时自动修改的示例,而在其他平台上可能没有声明.

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.

这篇关于git-切换到本地开发,然后返回功能分支以重置已修改/已添加文件的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆