Reputation: 30185
I tried a "merge --no-commit", and the --no-commit was ignored. 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?
Upvotes: 1
Views: 41
Reputation: 106470
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.
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.
If you want to prevent this from happening in the future, add --no-ff
to the options list; this will force Git to create a merge commit instead of no merge commit.
Upvotes: 2