Git changes being lost - why?

后端 未结 9 1792
梦如初夏
梦如初夏 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:24

    Had this issue and found the following snippet helped in analysis:

    git for-each-ref --sort=-committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate)%(color:reset))'
    

    This allows one see the last commit to the repo (sort=-committerdate) in all branches (refs/heads/).

    • sample observation:

      feature/blah_a - 9e492d9 - done b4 but committed l8r - (Sat Sep 15 14:29:53 2020)
      feature/blah_b - f98db7a - something - (Sat Sep 26 11:38:42 2020)
      feature/blah_c - 4ab7ee7 - somethang - (Tue Sep 24 17:38:25 2020)
      

      The reader will notice that feature/blah_a predates others but was merged later causing 'loss' of intervening check-ins.

    Another 'easy to remember' snippet is:

    git log -20 --date=iso --pretty=format:'%cd %h %d'
    

    While its output is terse, it gives a quick snapshot indicating if HEAD commit predates later references.

提交回复
热议问题