Removing useless merge commit with "filter-branch"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have a large project (~100K commits) and I need to split a part of
it into separate project. What I usually do in this case is

git filter-branch --prune-empty --index-filter 'git rm -rfq --cached
--ignore-unmatch UNNEEDED_DIRECTORIES' HEAD

that works more or less fine for me.

The original project has a lot of merge commits (don't ask me why).
Basically every non-merge commit is merged back to master branch
instead of rebasing on top of the master. In the command above I use
--prune-empty parameter that removes empty commits, but not their
merge points. This leaves a lot of "useless commit points" like this:

|
o      - merge commit that previously merged feature X
|\
| \
|  \
o  |   - real commit
|   |
|  /
|/
|


As of me such merge left-overs are completely useless and I would like
to remove them. Actually this task can be split into 2 steps:
1) Remove useless parents. A useless part is the one that points to a
commit that is *already* reachable by some other parent. This step
converts useless merge points to regular empty commits.
2) run filter branch with --prune-empty that removes such empty commits.


So my questions are:
1) What is the best way to remove "useless parents" as in the algorithm above?
2) Should such behavior (remove useless parent/merge commits) be
enabled when flag --prune-empty is used?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]