小编典典

没有自动提交的 Git 合并

all

是否可以做一个git merge,但没有提交?

“man git merge”是这样说的:

With --no-commit perform the merge but pretend the merge failed and do not autocommit,
to give the user a chance to inspect and further tweak the merge result before
committing.

但是当我尝试使用它git merge时,--no-commit它仍然会自动提交。这是我所做的:

$> ~/git/testrepo$ git checkout master
Switched to branch 'master'

$> ~/git/testrepo$ git branch
* master
  v1.0

$> ~/git/testrepo$ git merge --no-commit v1.0
Updating c0c9fd2..18fa02c
Fast-forward
 file1 |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

$> ~/git/testrepo$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)

随后git log显示来自 v1.0 分支的所有提交合并到 master 中。


阅读 170

收藏
2022-03-13

共1个答案

小编典典

在进行合并时注意输出 - 它是说Fast Forward

在这种情况下,您希望执行以下操作:

git merge v1.0 --no-commit --no-ff
2022-03-13