Git changes being lost - why?

后端 未结 9 1796
梦如初夏
梦如初夏 2021-02-13 20:42

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

In the current case, we can go back throug

9条回答
  •  囚心锁ツ
    2021-02-13 21:21

    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.

    Little illustration:

    commit XXXXXXXX:

    Line "bar" was added to file foo.

    ...work in progress...

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

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

    Investigation:

    1.I inspected history of file with:

    git log foo and gitk foo

    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.I searched for commits which could delete this line with "git log -S", something like:

    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.

    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.

提交回复
热议问题