I work at a branch called blaBla. master
gets a ton of commits from other folks. To keep update blaBla with master I do frequent git pull master and merge it into blaBla. But this clutters my branch with a ton of commits. I want to merge all new commits that have happened in master into one and then merge it into my branch. So when I do git log
I only see the commits that belong to that branch and those one single merge-commits. Nothing else

- 1,392
- 18
- 24
2 Answers
I want to merge all new commits that have happened in master into one and then merge it into my branch.
You really don't want to do this. The only reasonable options for bringing changes from master
into a feature branch are:
Do a normal
git merge master
without squashing its commits, so that Git can tell which commits your feature branch has in common withmaster
(otherwise you will likely suffer from numerous merge conflicts). Otherwise all the new changes in your squashed merge commit will seem like they were part of your new feature - not good.Do a
git rebase master
to replay your branch's changes on top of the latest frommaster
. This is my preferred workflow, as it structures your changes as "changes sincemaster
" regardless of whichmaster
you started with, but it comes with all the usual risks of rewriting history (e.g. communicate very carefully if you're going togit push --force
to a branch that others are depending on).
Update to reflect accepted answer: Or, change how you're visualizing the commits. git log --first-parent
will hide commits that were merged into the current branch. Though typically used for visualizing master
(which feature branches have been merged), it will also work to exclude master
commits that have been merged into a feature branch.

- 75,175
- 8
- 100
- 122
-
So in both of these I'm cluttering my local branch with thousands of commits that have occurred in master. How can I keep track of my branch changes that touch a small directory in master then? And if you do frequent merges after a couple of commits each time to scroll through your commtis seems like an impossible task unless scrolling through thousands of master commits to find your branch's stuff – Morteza Shahriari Nia Sep 21 '16 at 19:14
-
All I care about is seeing my commits, single-merge commits and relevant fixes for merge conflicts nothing else. How do I do that? – Morteza Shahriari Nia Sep 21 '16 at 19:16
-
1One option is to use `git log --first-parent` to look at your branch - you will see "Merge branch 'master' into blaBlah" (and its conflict resolutions), but not the commits that were merged in. I don't understand the "cluttering my local branch" comment with regard to `rebase` - if you think of branches as "changes since branching from `master` (i.e. `git log master..`), post-`rebase` you will continue to see the same series of commits. – dahlbyk Sep 21 '16 at 19:22
-
I guess `git log --first-parent` was the answer. Tnx! – Morteza Shahriari Nia Sep 21 '16 at 19:31
There seems to be a couple ways of doing this, but it might make pushing your changes up to master a lot harder if you're only doing this locally. Git really doesn't like history being re-written at all

- 1
- 1
-
As you mentioned modifying history is a big no-no. I don't want to modify master. Just combine its commits for the purpose of merge to my branch and don't touch anything else. Maybe this is more a git log visualization thing than actually combining commits. So when you do `git log` All you see is my commits, single-merge events and relevant fixes for merge conflicts nothing else. no other thousands of commits to see – Morteza Shahriari Nia Sep 21 '16 at 19:21