Git更改丢失了-为什么? [英] Git changes being lost - why?

查看:274
本文介绍了Git更改丢失了-为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的开发团队正在使用git,并且最近至少两次丢失了对文件的更改.我们正在使用私有的Github仓库.

Our development team is using git and we've lost changes to files at least twice recently. We are using private Github repos.

在当前情况下,我们可以回顾Github上的日志,并查看我对文件所做的一些更新.后来,另一位团队成员更改了文件的其他部分,它似乎破坏了我的更改.我还是在本地.

In the current case, we can go back through the logs on Github and see some updates I made to a file. Later, another team member changed a different part of the file, and it appears to have destroyed my changes. I still have them locally.

还有其他人经历过吗?任何原因或解决方案?

Has else anybody experienced this? Any causes or solutions?

我不会认为,任何人都在做基础或花哨的事情,只是拉动而已.

I don't think anybody is doing any rebasing or anything fancy - just pulling and pushing.

推荐答案

我想补充几句话.我最近注意到git中的行为很奇怪.因此,我的团队遇到了很大的问题. 我不知道它是怎么发生的,但是我的回购中的历史似乎不一致.

I would like to add my few words. I lately noticed very strange behavior in git. My team had big problems because of that. I don't know how it happened but it seems that history in my repo is inconsistent.

小插图:

提交XXXXXXXX:

commit XXXXXXXX:

"bar"行已添加到文件foo中.

Line "bar" was added to file foo.

...正在进行中...

...work in progress...

以后有很多提交(比如说大约100个):

lots of commits later(let's say about 100):

该文件中的行"bar"不再存在!

Line "bar" no longer exists in this file!!

调查:

1.我用以下方法检查了文件的历史记录:

1.I inspected history of file with:

git log foo 和 gitk foo

git log foo and gitk foo

我甚至将每次提交的连续blob与外部工具(gvimdiff)进行了比较. 有趣的是,我发现了两个提交(我们称它们为YYY和ZZZ). 来自提交YYY的文件foo的Blob由"bar"组成,但来自ZZZ的Blob没有.
当我使用gitk(和gitweb)检查那些提交的commitdiffs时,我注意到在ZZZ中没有删除"bar"行的操作. 两者之间有可能发生混合并溶解在稀薄的空气中吗?
或者也许提交ZZZ只是删除了我的行,而git(或gitk)中嵌入的差异工具坏了?

I even compared consecutive blobs from every commit with external tool(gvimdiff). It's interesting thing that I found two commits(let's call them YYY and ZZZ). Blob of file foo from commit YYY consisted "bar" but blob from ZZZ didn't.
When I inspected commitdiffs of those commits with gitk(and gitweb) I noticed that there is no operation of removing line "bar" in ZZZ. Is it possible that there was some commit in between and dissolved in thin air?
Or maybe commit ZZZ just removed my line and diff tool embedded in git(or gitk) is broken?

2.我搜索了可以用"git log -S"删除此行的提交,例如:

2.I searched for commits which could delete this line with "git log -S", something like:

git log -S'bar'-foo

git log -S'bar' -- foo

事实证明,此行从未删除.实际上,它被添加了两次.第一次将其引入项目中,第二次将其作为紧急错误修复再次添加.

It turns out that this line was never deleted. As a matter of fact it was added two times. First time when it was introducted to project and second time when it was added again as an urgent bugfix.

我真的很喜欢使用git,甚至说服很少的朋友使用它,但是如果这种魔力继续发生,我将不得不开始寻找替代方法.

I really like using git and even persuaded few friends to use it but if that kind of magic continue to happen, I will have to start searching for alternatives.

这篇关于Git更改丢失了-为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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