Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I make git merge --ff act like --ff-only?

Tags:

git

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.

like image 710
amalloy Avatar asked Feb 20 '14 19:02

amalloy


People also ask

How do you merge without fast forward?

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.

What is no FF in git merge?

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.

How do I merge FF?

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.

How do I merge without committing?

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.


1 Answers

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à.

like image 179
Paul Hicks Avatar answered Sep 28 '22 02:09

Paul Hicks