2016-07-15 80 views
0

我有一個情況我的樹枝看起來像這樣:Git:如何刪除出現在另一個分支上的重複提交?

* d3b91f2 (HEAD, origin/narrowdown_lblrtmprogram, narrowdown_lblrtmprogram, lowercase_main_src_code) resolve gi 
t-pull conflict. gitignore *.mod and *.so 
|\ 
| * 0ed828f number all the markers which a typical run goes past 
| * 7a9fd6a gitignore *.o and lblrtm executables 
| * 40e824a stop tracking lblrtm/lblrtm_v12.2_linux_intel_dbl 
| * cfb6866 stop tracking some previously tracked files but are now in .gitignore 
| * 314451c lay down markers in main program 
| * a0d6edf gitignore *.mod 
| * 5e9352a gitignore `runs/` directory 
* | 2e48384 number all the markers which a typical run goes past 
* | a0db0ed gitignore *.o and lblrtm executables 
* | df52ddc stop tracking some previously tracked files but are now in .gitignore 
* | 37fc6d1 lay down markers in main program 
* | 9deee6a gitignore *.mod 
* | 9ae357a (origin/trace_lblrtm_lw_flux_calc, trace_lblrtm_lw_flux_calc) gitignore runs/ 
* | 4ce55a0 gitignore *.o and lblrtm executables 
* | 3691140 stop tracking lblrtm/lblrtm_v12.2_linux_intel_dbl 
|/ 
| * 3c8edd0 (origin/master, master) gitignore runs/ 
| * 969a8e1 gitignore *.o and lblrtm executables 
|/ 
* 11ed99d Revert "Add write() statements to mark path through lblrtm source code for example solar run" 

似乎有兩個分支是在最上面的合併提交d3b91f2。但是,從36911402e48384的提交與從5e9352a0ed828f的提交實際上是相同的。有沒有辦法擺脫從5e9352a0ed828f的冗餘提交?因爲看看

[[email protected] aerlbl_v12.2_package]$ git log -10 narrowdown_lblrtmprogram --oneline 
d3b91f2 resolve git-pull conflict. gitignore *.mod and *.so 
2e48384 number all the markers which a typical run goes past 
a0db0ed gitignore *.o and lblrtm executables 
df52ddc stop tracking some previously tracked files but are now in .gitignore 
37fc6d1 lay down markers in main program 
9deee6a gitignore *.mod 
9ae357a gitignore runs/ 
4ce55a0 gitignore *.o and lblrtm executables 
3691140 stop tracking lblrtm/lblrtm_v12.2_linux_intel_dbl 
0ed828f number all the markers which a typical run goes past 

[[email protected] aerlbl_v12.2_package]$ git log -10 --oneline lowercase_main_src_code 
d3b91f2 resolve git-pull conflict. gitignore *.mod and *.so 
2e48384 number all the markers which a typical run goes past 
a0db0ed gitignore *.o and lblrtm executables 
df52ddc stop tracking some previously tracked files but are now in .gitignore 
37fc6d1 lay down markers in main program 
9deee6a gitignore *.mod 
9ae357a gitignore runs/ 
4ce55a0 gitignore *.o and lblrtm executables 
3691140 stop tracking lblrtm/lblrtm_v12.2_linux_intel_dbl 
0ed828f number all the markers which a typical run goes past 

這些提交似乎不屬於任一分支narrowdown_lblrtmprogram或分支機構lowercase_main_src_code,所以我不能使用git branch -d

回答

1

交互式重新分配可能會有所幫助。

git rebase -i 11ed99d 

和flag提交你想用d刪除標記。

只要確保有備份分支,或者如果出現問題,您將不得不執行git reflog

+0

謝謝,這個作品!雖然後來我意識到重複的提交實際上在同一個分支上,考慮到我的問題應該成爲「如何刪除提交歷史記錄中的一系列提交」,這裏已經提到了這個問題http:// stackoverflow。 COM /問題/ 1338728 /刪除-提交 - 從-A-分支中,飯桶。 – Jack

相關問題