如何在没有完整回购的情况下展示git中的关键提交

问题描述:

与我们所有人一样,我已经完成了一些关键代码提交,这些提交显示了我遵循SOLID范式,精心编写的算法等的逻辑。在GitLab或GitHub上找到类似的界面(并排)差异显示。如何在没有完整回购的情况下展示git中的关键提交

有没有办法做到这一点(而不是截图),不涉及复制整个存储库?在这种情况下,安全不是问题,客户也不会介意或反对,但显然复制整个回购并不是一个好的解决方案。

- 编辑 - 因为它可能是GitHub上是唯一或最佳的解决方案的情况下,也许是一个更好的问题或可能的方向是这样的:

所以master分支有提交/合并A到Z.我的合并是J,M和X.我可以通过I压缩A,显示J> I的合并,通过L压缩K,显示M> L等的合并?

+0

该项目是否已经托管在github/gitlab/etc上?它会是吗?然后,您只需提供适当的差异网址链接... – larsks

+0

它是和可以。但我只是想知道除此之外是否还有其他办法。看到我上面的编辑。 –

+0

我不知道你的意思是“通过我压缩A”。如果你想显示J> I之间的差异,你只关心那些提交之间的差异,你通过链接到I.A-H是不相关的。例如,为了显示我添加到项目中的功能,我可以直接链接到[提交](https://github.com/git/git/commit/f6f2a9e42d14e61429af418d8038aa67049b3821)。 – larsks

如果你愿意为此设置一个新的存储库,你可以做你想做的。比方说,你有10个提交一个存储库:

$ git log --oneline 
2c82196 this is commit 10 
2bff8eb this is commit 9 
7020be2 this is commit 8 
0aea964 this is commit 7 
c5d5fcb this is commit 6 
c80dc97 this is commit 5 
591367e this is commit 4 
c2524c8 this is commit 3 
3aa5e3a this is commit 2 
33da02c this is commit 1 

你想在提交5.只要运行在整个历史的互动变基凸显您的更改:

这将让你挑名单看起来像:

pick 2d6696b this is commit 1             
pick c5c7389 this is commit 2             
pick c8cd62d this is commit 3             
pick da0fb52 this is commit 4             
pick 6ec5fac this is commit 5             
pick 7508d6f this is commit 6             
pick 6dede0f this is commit 7             
pick 9e995b7 this is commit 8             
pick 8b1299a this is commit 9             
pick 44a32ee this is commit 10             

变化picksquash的承诺2-4:

pick 2d6696b this is commit 1             
squash c5c7389 this is commit 2             
squash c8cd62d this is commit 3             
squash da0fb52 this is commit 4             
pick 6ec5fac this is commit 5             
pick 7508d6f this is commit 6             
pick 6dede0f this is commit 7             
pick 9e995b7 this is commit 8             
pick 8b1299a this is commit 9             
pick 44a32ee this is commit 10             

...并保存该文件。这将压扁提交2,3和4到提交一,留给你以下历史:

$ git log --oneline 
9cec0a1 this is commit 10 
b39ec3d this is commit 9 
3578beb this is commit 8 
1ce80b9 this is commit 7 
2faaf79 this is commit 6 
ff57ad9 this is commit 5 
6a53018 this is commit 1 

现在承诺5只有一个父母。你可以为后续的提交做同样的事情。再次运行:

,然后编辑您的领料单壁球所有后续提交到提交6:

pick 6a53018 this is commit 1             
pick ff57ad9 this is commit 5             
pick 2faaf79 this is commit 6             
squash 1ce80b9 this is commit 7             
squash 3578beb this is commit 8             
squash b39ec3d this is commit 9             
squash 9cec0a1 this is commit 10             

这可以让你:

$ git log --oneline 
a7a03ba this is commit 6 
01253c9 this is commit 5 
a903311 this is commit 1 

你可以明显也只是用来git reset放弃第5次提交后的所有历史记录。

+0

我接受这个,因为它是彻底的,给了我一个很好的途径进行。谢谢。 –