git checkout远程分支显示无关文件? [英] git checkout remote branch shows extraneous files?

查看:654
本文介绍了git checkout远程分支显示无关文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

master分支有这些文件和文件夹(简体):

  C:\ Local \TickZoom\Project> ls 
file.txt name.txt public

公共分支正在跟踪供应商存储库并已被子树
合并为上面主分支中的公共文件夹。公共只有三个
文件夹(简体):

  C:\ Local \TickZoom\Project> ls 
平台提供商www

从公共转换为主时,它的行为正确。



然而,当从主人切换到公众时,会发生奇怪的事情。
它包含所有的文件和文件夹:

  C:\ Local \TickZoom\Project> ; git checkout public 

C:\ Local \TickZoom\Project> ls
file.txt name.txt public
平台提供者www

然而,检查git状态并没有发生任何变化。



我发现'git reset --hard'修复了公开的背景。



CLUE:看起来这只发生在一次新的提交
掌握之后。 git会自动合并吗?



在'git reset --hard'之后,将
掌握并返回到公共工作状态的结帐


第一个,我认为它是固定的,但是下一次我做了一个改动后又发生了
。让我再试一次
来确定...



现在,我无法复制它。但它确实发生了两次。

另一个CLUE是我第一次做git reset --hard
,它抱怨文件被进程锁定。



在违规程序关闭后,git reset --hard
成功,然后在两个分支之间进行结账。



那么结账会被文件锁定和
默默失败混淆?这会更好,这就是问题
以同样的方式失败git reset --hard不仅仅是报告
成功并且有一个混乱的工作区。



Wayne

解决方案

使用此解决方案



git clean -f -d -X



这只清除由.gitignore忽略的文件和包含它们的所有空目录。

我现在在签出之前在脚本中执行此操作分支机构来自完全不同的存储库。



在同一软件之间切换分支时,这不是一个问题。



韦恩


master branch has these files and folders (simplified):

C:\Local\TickZoom\Project>ls
file.txt         name.txt      public

public branch is tracking a vendor repository and has been subtree merged as public folder in master branch above. public has three folders only (simplified):

C:\Local\TickZoom\Project>ls
platform  providers  www

When switching from public to master it behaves correctly.

However, when switching from master to public, an odd thing happens. It has all the files and folders of both combined:

C:\Local\TickZoom\Project>git checkout public

C:\Local\TickZoom\Project>ls
file.txt  name.txt   public
platform  providers  www

However, checking git status says nothing has changed.

I discovered that 'git reset --hard' fixes public back.

CLUE: It seems that this only happens after making a new commit to master. Does git do some kind of automatic merge?

After 'git reset --hard', the checkout to master and back to public work fine, even if repeatedly.

The first, I thought it was fixed but it occurred again the next time I made a change. Let me try that one more time now to make sure...

Now, I can't reproduce it. But it did happen twice.

One other CLUE is that the first time I did a git reset --hard it complained about files being locked by processes.

After the offending programs were closed, the git reset --hard succeeded and then the checkout worked between the two branches.

So does the checkout get confused by files being locked and "silently" fail? It would be better, it that's the problem to fail the same way git reset --hard does than just reporting success and having a jumbled workspace.

Any other wisdom or options to set on git checkout to avoid this will be appreciated.

Wayne

解决方案

use this to resolve

git clean -f -d -X

This cleans out only files ignored by your .gitignore and all empty directories that contain them.

I now do this in a script before checkout of branches that are from totally different repositories.

This isn't such an issue when switching branches between the same software.

Wayne

这篇关于git checkout远程分支显示无关文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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