Home > Blockchain >  Why is -f being called twice in the git command git merge --no-ff <branch-name>?
Why is -f being called twice in the git command git merge --no-ff <branch-name>?

Time:05-04

While looking up syntax for git parameters involving one dash versus two dashes. I came across this post which explains that single dashes allow you to specify multiple single letter parameters with one dash and double dashes are for multi-letter parameters.

So in the case of git merge --no-ff <branch-name> is -ff calling -f twice? If so, why?

CodePudding user response:

So in the case of git merge --no-ff <branch-name> is -ff calling -f twice?

No, it isn't.

--no-ff is the complete long option. Long options may contain dashes, because only whitespace separates command line arguments and a long option is always an entire command line argument (unlike short options, where one command line argument can contain multiple options, .i.e. -bar contains b a and r).

CodePudding user response:

--ff just means fast forward.

Semantically speaking:

  • a fast-forward merge of a branch other in a current feature branch is a trivial merge where the SHA1 of feature is just "bumped" to other (this is not always possible, only if other is a child-commit-or-so of feature)

  • a non-fast-forward merge of other in feature is "a true merge" which results in the creation of a new merge commit in branch feature, which then has two parent commits.

Reference

See also the online refman which indicates there are three related CLI flags:

https://git-scm.com/docs/git-merge#Documentation/git-merge.txt---ff

--ff
--no-ff
--ff-only

Specifies how a merge is handled when the merged-in history is already a descendant of the current history.

  • Related