2017-09-28 75 views
0

與我們所有人一樣,我已經完成了一些關鍵代碼提交,這些提交顯示了我遵循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

回答

2

如果你願意爲此設置一個新的存儲庫,你可以做你想做的。比方說,你有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

我接受這個,因爲它是徹底的,給了我一個很好的途徑進行。謝謝。 –

相關問題