[英]Git: how to delete repeated commits that appear on another branch?
I have a situation where my branches look like this: 我的情况是我的分支看起来像这样:
* 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"
There appears to be two branches that are merged at the topmost commit d3b91f2
. 似乎有两个分支在最高提交
d3b91f2
处合并。 However, commits from 3691140
to 2e48384
are effectively the same as those from 5e9352a
to 0ed828f
. 然而,从承诺
3691140
至2e48384
是有效那些从同一5e9352a
到0ed828f
。 Is there a way to get rid of those redundant commits from 5e9352a
to 0ed828f
? 有没有办法摆脱那些从
5e9352a
到0ed828f
多余提交? Because looking at 因为看着
[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
and 和
[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
these commits do not seem to belong to either branch narrowdown_lblrtmprogram
or branch lowercase_main_src_code
, so I cannot use git branch -d
. 这些提交似乎不属于
narrowdown_lblrtmprogram
分支或lowercase_main_src_code
分支,因此我不能使用git branch -d
。
interactive rebase might be helpful. 交互式变基可能会有所帮助。
git rebase -i 11ed99d
and flag commits you want to delete with d
marker. 并使用
d
标记标记要删除的提交。
Just make sure to have a backup branch or you will have to do a git reflog
if something fails. 只需确保有一个备份分支,否则如果失败则必须执行
git reflog
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.