简体   繁体   English

Git的片状行为-不提交?

[英]Flaky Behavior of Git --no-commit?

I tried a "merge --no-commit", and the --no-commit was ignored. 我尝试了“合并--no-commit”,并且--no-commit被忽略了。 Why? 为什么?

Here is exactly what happened: 这正是发生的情况:

baria@DESKTOP-057K4L5 MINGW64 /c/repos/mobile-solutions (feature/create-new-theme)
$ git status
On branch feature/create-new-theme
Your branch is behind 'origin/feature/create-new-theme' by 1 commit, and can be fast-forwarded.
(use "git pull" to update your local branch)
nothing to commit, working directory clean

baria@DESKTOP-057K4L5 MINGW64 /c/repos/mobile-solutions (feature/create-new-theme)
$ git merge --no-commit origin/feature/create-new-theme
Updating 0010daa..d835f24
Fast-forward
.../Views/CarrierAccountLines/CarrierAccountLineMenu.cshtml         | 3 +--
src/Max.Web/wwwroot/master/sass/app2/custom/all.scss                | 6 ++++++
2 files changed, 7 insertions(+), 2 deletions(-)

baria@DESKTOP-057K4L5 MINGW64 /c/repos/mobile-solutions (feature/create-new-theme)
$ git status
On branch feature/create-new-theme
Your branch is up-to-date with 'origin/feature/create-new-theme'.
nothing to commit, working directory clean

I expected no commit to be made. 我希望没有承诺。 What am I misunderstanding? 我有什么误会?

git merge --no-commit won't create a merge commit automatically, but this only applies if the two branches you're merging actually require a merge commit. git merge --no-commit 不会自动创建合并提交 ,但这仅在您要合并的两个分支实际上需要合并提交时才适用。

In this case, your branches were able to be fast-forwarded , and thus no commit would have been created. 在这种情况下,您的分支能够被快速转发 ,因此不会创建任何提交。

If you inspect your history git --log --graph --oneline --pretty --decorate , you'll observe that there's no merge commit, and the last commit(s) to your branch are identical to the one that you merged from. 如果检查历史记录git --log --graph --oneline --pretty --decorate ,则会发现没有合并提交,分支的最后一次提交与您合并的分支相同从。

If you want to prevent this from happening in the future, add --no-ff to the options list; 如果要防止将来发生这种情况,请在选项列表中添加--no-ff this will force Git to create a merge commit instead of no merge commit. 这将迫使Git创建一个合并提交而不是没有合并提交。

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

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