1

I am merging changes of one branch to another using no-ff and no-commit flags as following.

git merge --no-ff --no-commit

But when I commit with my own message and push it, github still shows detail as merged branch a into b

How can I only take changes without taking any commit or any change metadata details?

1
  • If you want a fully linear structure with no merge commits, you'll need to make sure that every branch being merged already contains the HEAD of the branch you're merging into. You can ensure this with git rebase Commented Aug 15, 2022 at 9:04

2 Answers 2

4

I think you have a misconception about what merge --no-commit does. You appear to think that it will not create a relation to the merged branch when you commit? That's not the case. --no-commit does the whole thing and delays the commit (you might have things to do before the commit is done)... but then the revision is created (when you actually run git commit later). it will relate to the merged branch, and you will end up with a merge revision. It is exactly the same as doing:

git merge --no-ff # do stuff that you want to include in the merge revision git add . # add those changes git commit --amend --no-edit 

If what you want is avoid the merge revision, you might try this instead:

git merge --squash the-other-branch 

Given that squash does not create a relation (at least, in terms of parents.... you might have some of that in the comment, which is irrelevant to git when establishing parenting relations) to the merged branch, it's not possible to see that the branch has been merged.

Or this other longer and completely unnecessary path:

git merge --no-ff # let it run the merge, just as usual git reset --soft HEAD~ # go back to the parent revision git commit -C HEAD@{1} # commit, no merge, use the same comment as the original merge commit 
Sign up to request clarification or add additional context in comments.

Comments

1

Quote from reference document at https://git-scm.com/docs/git-merge#_options

--commit
--no-commit
Perform the merge and commit the result. This option can be used to override --no-commit.

When you use --no-commit , it just does not conduct a combo commands, then you commit manually, it likes normal --no-ff

1 Comment

Is "combo commands" a typo / auto-complete fail? That whole sentence doesn't make much sense.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.