Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge GIT branch without commit log

Tags:

git

merge

Currently when I'm using GIT I create a branch for each job and make various commits before I'm finished. I then merge back with my master branch and push upstream. I'm likely to have several branches at any one time and also flick between them mid-job as things crop up.

But most of these commits are just save points, i.e. not that important in the grand scheme of things. So when I merge the branch, I'd like it if the branch logs didn't merge with the master logs.

Is there a way to just merge the log message for commit g below (and not commits c or e)?

a [master]  | b (create branch 'job') |\ | \ |  c  |  | d  e |  | f  g (next step is to merge 'job' branch with 'master') 
like image 281
Adam Avatar asked Nov 08 '10 10:11

Adam


People also ask

How do I merge a branch without committing?

Thus, if you want to ensure your branch is not changed or updated by the merge command, use --no-ff with --no-commit.

Does git merge require commit?

There are two main ways Git will merge: Fast Forward and Three way. Git can automatically merge commits unless there are changes that conflict in both commit sequences.

What does git merge -- no commit do?

The --no-commit prevents the MERGE COMMIT from occuring, and that only happens when you merge two divergent branch histories; in your example that's not the case since Git indicates that it was a "fast-forward" merge and then Git only applies the commits already present on the branch sequentially.


1 Answers

I consider merge --squash extremely useful when I use a "branch per feature" approach. My commit history in temporary branches is a complete garbage, absolutely meaningless. And I really want to be unable to see that history anymore, not just to be able to skip it.

When the commits go to code review, it is important not to create extra commits.

like image 198
Ellioh Avatar answered Oct 29 '22 16:10

Ellioh