2014-09-12 24 views
3

我们的git分支存在一个奇怪的问题,我希望更多的是关于我们的理解,而不是像这样的问题。我将描述我们的工作流程,尽我所能确保我们不会错过某些明显的东西:为什么git log不按时间顺序显示,代码已被删除?

其中一个团队用git checkout -b newproject做了一个分支,然后做了一些更改,然后用git push -u origin new project推送了这些更改。然后其他开发者加入该项目,使用git fetch origin,然后git checkout newproject

接下来,工作流程如下。开发人员会定期更改,git add新的和修改的文件以及git commit。然后,当他们希望其他人看到他们的更改时,他们将执行git pull origin newproject以获得自上次拉出以来的任何更改,然后是git push -u origin newproject

注:/etc/gitconfig,我们有以下几点:

[branch] 
autosetuprebase = always 

我们经常会得到冲突时pull ING,因为我们在同一个文件的工作很多。当我们这样做时,我们得到了手动解决冲突的指令,然后运行git rebase --continue我们打开文件,选择我们想保留的代码并进行必要的更改并保存。然后,我们git add filename.ext解决时,然后运行git rebase --continue。在完成之后,git status显示没有变化,在newproject分支上并且在X提交之前,我们使用git push -u origin newproject

今天早上我们注意到大量的代码突然失踪。当运行git log时,我们注意到的第一件事是它不是按照时间顺序as the manual suggests

commit bc0903fc5795425908f335cebcab11055869d75d 
Author: billy <[email protected]> 
Date: Thu Sep 11 15:29:37 2014 +0100 

    Add responsive skin to sectionProducts 

commit 7833850313c2974c3b8cbc75383b1834fbf4bf93 
Author: bob <[email protected]> 
Date: Thu Sep 11 14:44:37 2014 +0100 

    Rewrite the way breadcrumbs are generated and output to the page 

commit 09d1318d9e7249e9e45826d7ddc33f23fc5974b1 
Author: bob <[email protected]> 
Date: Thu Sep 11 11:25:21 2014 +0100 

    Fix styles for video and featured product boxes, fix miscellaneous bugs and remove obselete code 

commit 13f01644935092b490be55b6738f500f0f5fcb2e 
Author: bob <[email protected]> 
Date: Thu Sep 11 08:31:03 2014 +0100 

    Fix section.html, add featured products, star buy products and product videos 

commit 01b3bfb3c20f74ea437b221711deabc970f670d8 
Author: bob <[email protected]> 
Date: Fri Sep 12 08:45:19 2014 +0100 

    Refine code for breadcrumbs 

commit 0303bae79f7ff2e84221e0db3f88d3630d4afa91 
Author: bob <[email protected]> 
Date: Thu Sep 11 15:53:06 2014 +0100 

    Modify getBreadcrumbTrail so that it attempts to take the correct route when recursing 

commit 1ae5f00814bf216eda5449a6e8d89123b124fad8 
Author: bob <[email protected]> 
Date: Thu Sep 11 14:44:37 2014 +0100 

    Rewrite the way breadcrumbs are generated and output to the page 

它也出现了一些提交重复。另一点需要注意的是,其中一位开发人员提到,当他们看到一些冲突并解决它们时,然后运行git rebase --continue,他们显示了另一个冲突列表。在能够推动之前,它们在所有问题都解决之前发生了几次。

更新:我们已经注意到,这个问题是最初想到的一个更容易解释的问题。直到鲍勃推他的承诺,最多承诺与日期Fri Sep 12 08:45:19 2014 +0100,一切都是正确的。它按时间顺序排列,代码正确。接下来的3个提交鲍勃其实是提交前我刚才提到的3个提交,并加入比利推动他的变化。所以,他们是鲍勃的承诺,但不知何故重新加入比利。另请注意,最终的提交并未重新添加,这是大部分问题似乎源于此的地方。

到Illustrator这一点更好,我提出以下几点:

87e9a4e Add sectionGroup.html to templates_safelincs 
bc0903f Add responsive skin to sectionProducts 
7833850 Rewrite the way breadcrumbs are generated and output to the page 
09d1318 Fix styles for video and featured product boxes, fix miscellaneous bugs and remove obselete code 
13f0164 Fix section.html, add featured products, star buy products and product videos 
01b3bfb Refine code for breadcrumbs 
0303bae Modify getBreadcrumbTrail so that it attempts to take the correct route when recursing 
1ae5f00 Rewrite the way breadcrumbs are generated and output to the page 
2cc0525 Fix styles for video and featured product boxes, fix miscellaneous bugs and remove obselete code 
cc3c86b Fix section.html, add featured products, star buy products and product videos 

任何人都可以解释我们做错了什么?

+2

有信息丢失(所以不能确切说出发生了什么),但请注意,当你'git rebase',你*复制*提交(然后放弃原来的赞成新副本)。如果您仅对自己的*,未推送的提交进行重定位,则没有其他人拥有您的旧版本,但如果您以某种方式重新设置了某个*其他*的(推送/发布)提交,则也会复制它们*。这几乎肯定发生了什么。要将两个副本都放到历史记录中,您可以将副本与他们的副本合并(这将显示在'--graph'输出或gitk等中)。 – torek 2014-09-12 11:27:29

+0

看来这可能是有效的。是否还有更多信息可以帮助您从哪里寻找出发点?我有点迷路。附: '--graph'输出只显示一条线性路径。 – LeonardChallis 2014-09-12 11:31:13

+1

真的需要知道每个用户做了什么,或者从服务器上看/看过很多日志。至于日期排序,请注意每个提交都有* 2个*时间戳:作者日期和提交者日期。日志排序默认使用提交日期,而“媒体”格式只显示作者日期。 (当使用'--graph'时,日志排序被强制为'--topo-order'。) – torek 2014-09-12 11:40:45

回答

0

为了完整性,我会在此处发布原因。

简而言之,我们正在重写公共历史,which is bad。我们现在所做的现在只是从主人到我们的功能分支的重新分配,并且当它与我们自己的头部应用的提交保持一致时,然后我们合并到主人。实际上,我们也开始压制提交。尽管我们可能会在几周前做出最初的提交。

0

我觉得这个序列会产生你所看到的图表:

  1. 鲍勃推未显示三个提交,称他们为A,B,C,其母公司是cc3^
  2. 比利pull --rebase的他在它们之上工作,但决定不推任何事情
  3. 鲍勃出于某种原因要追溯到和重做那些三个提交,生产cc32cc1ae为新的A,b,C,并与03001b继续。
  4. bob力推这个新的历史,这从比利的分歧cc3^
  5. 比利现在pull --rebase s再次。所以a,b,c和两个承诺被重新分配到01b,获得13f,09d,783,作为他原来的a,b,c和他自己的bc087e的新改版版本。
相关问题