繁体   English   中英

Git:如何删除出现在另一个分支上的重复提交?

[英]Git: how to delete repeated commits that appear on another branch?

我的情况是我的分支看起来像这样:

*   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多余提交? 因为看着

[jk@nuwaln01 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

[jk@nuwaln01 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

交互式变基可能会有所帮助。

git rebase -i 11ed99d

并使用d标记标记要删除的提交。

只需确保有一个备份分支,否则如果失败则必须执行git reflog

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM