是否可以做一个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
显示合并到 master 的 v1.0 分支的所有提交。
注意合并时的输出 - 它说Fast Forward
.
在这种情况下,您需要执行以下操作:
git merge <name-of-branch> --no-commit --no-ff
重要的:如果您这样做,那么您将无法对暂存区域中的文件进行任何更改,例如您无法删除/添加文件或对文件进行任何更改。
如果您想合并更改然后提交,就像您手动键入合并的所有更改一样(与传统合并相反),您需要运行rm .git/MERGE_HEAD
之后,这将迫使 git 忘记发生了合并。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)