I sometimes want to do a --ff-only
merge, and it's a little awkward to tab-complete, because --ff
exists. But --ff
is the default behavior, and I can't imagine ever wanting to specify it explicitly. Can I make --ff
a synonym for --ff-only
? I know I can make an alias like ff-merge
, but I'm not thrilled about that solution. I'd also be happy with a solution that causes --ff<TAB>
to complete to --ff-only
.
To merge branches without fast forwarding in Git, first, initialize a directory with the “$ git init” command. Then, create a new file, add it, and commit changes with a message to the Git repository. After that, create and switch to the new branch. Again create, add a new file in the switched branch and commit it.
The Git merge --no-ff command merges the specified branch into the command in the current branch and ensures performing a merge commit even when it is a fast-forward merge. It helps in record-keeping of all performed merge commands in the concerning git repo.
Fast forward merge can be performed when there is a direct linear path from the source branch to the target branch. In fast-forward merge, git simply moves the source branch pointer to the target branch pointer without creating an extra merge commit. Let us look at an example implementing fast-forward merge.
With --no-commit perform the merge and stop just before creating a merge commit, to give the user a chance to inspect and further tweak the merge result before committing. Note that fast-forward updates do not create a merge commit and therefore there is no way to stop those merges with --no-commit.
Answering the bit
I'd also be happy with a solution that causes --ff to complete to --ff-only.
In bash, find which script is used to configure your git completions. On my system it's /etc/bash.completion.d/git-completion.bash
.
In there, find the bit specifying the options for git merge. In my script, there's a variable __git_merge_options
. Your best bet is to search for --ff-only
.
In that variable, remove --ff
, so that only --ff-only
and --no-ff
(and other unrelated options) remain.
Save and source that script.
Voilà.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With