我想从线性提交树中删除选定的提交日志项,这样这些项就不会显示在提交日志中。
我的提交树看起来像这样:
R--A--B--C--D--E--HEAD
我想删除B和C条目,这样它们就不会显示在提交日志中,但是应该保留从A到D的更改。也许通过引入一次提交,这样B和C就变成了BC,树看起来就像。
R--A--BC--D--E--HEAD
或者,理想情况下,A后面直接是D。D'表示从A到B, B到C, C到D的变化。
R--A--D'--E--HEAD
这可能吗?如果是,怎么做?
这是一个相当新的项目,所以目前还没有分支,因此也没有合并。
刚刚收集了所有人的答案:(我是git的新手,请仅供参考)
Git重基删除任何提交
git 日志
-first check from which commit you want to rebase
我们回来了
-Here i want to rebase on the second last commit- commit count starts from '1')
-this will open the command line editor (called vim editor i guess)
然后屏幕看起来会是这样的:
pick 0c2236d Added new line.
Rebase 2a1cd65..0c2236d onto 2a1cd65 (1 command)
#
Commands:
p, pick = use commit
r, reword = use commit, but edit the commit message
e, edit = use commit, but stop for amending
s, squash = use commit, but meld into previous commit
f, fixup = like "squash", but discard this commit's log message
x, exec = run command (the rest of the line) using shell
d, drop = remove commit
#
These lines can be re-ordered; they are executed from top to bottom.
#
If you remove a line here THAT COMMIT WILL BE LOST.
#
However, if you remove everything, the rebase will be aborted.
#
Note that empty commits are commented out ~ ~
~
~
~
~
~
~
~
~
~
这里根据您的需要更改第一行(使用上面列出的命令,例如。'drop'删除提交等)
编辑完成后,按“:x”保存并退出编辑器(这仅适用于vim编辑器)
然后
git push
如果它的显示问题,那么你需要强行将更改推到远程(非常关键:如果你是团队工作,不要强行推)
Git push -f origin
刚刚收集了所有人的答案:(我是git的新手,请仅供参考)
Git重基删除任何提交
git 日志
-first check from which commit you want to rebase
我们回来了
-Here i want to rebase on the second last commit- commit count starts from '1')
-this will open the command line editor (called vim editor i guess)
然后屏幕看起来会是这样的:
pick 0c2236d Added new line.
Rebase 2a1cd65..0c2236d onto 2a1cd65 (1 command)
#
Commands:
p, pick = use commit
r, reword = use commit, but edit the commit message
e, edit = use commit, but stop for amending
s, squash = use commit, but meld into previous commit
f, fixup = like "squash", but discard this commit's log message
x, exec = run command (the rest of the line) using shell
d, drop = remove commit
#
These lines can be re-ordered; they are executed from top to bottom.
#
If you remove a line here THAT COMMIT WILL BE LOST.
#
However, if you remove everything, the rebase will be aborted.
#
Note that empty commits are commented out ~ ~
~
~
~
~
~
~
~
~
~
这里根据您的需要更改第一行(使用上面列出的命令,例如。'drop'删除提交等)
编辑完成后,按“:x”保存并退出编辑器(这仅适用于vim编辑器)
然后
git push
如果它的显示问题,那么你需要强行将更改推到远程(非常关键:如果你是团队工作,不要强行推)
Git push -f origin