开发者

How to split commits automatically into different branches?

For my school projects, I was used to have one big repo with several subdirectories for the specific projects. Because I had no time, I always commited anything into the master branch.

The problem is, that this turns out to be unp开发者_运维百科racticable, as it becomes more and more difficult to revert older commits or figuring out which commit belongs to what whithout reading the message.

Currently it looks like this:

Dir-tree:

projects/
  projectA/
  projectB/
  projectC/
  ...

Repo:

A---B---C---D---E---F---G<master>

I found out, that almost all commit (apart from about five, which I can fix by hand) just modify files in one of these folders.

Is there an easy (automatred?) way (script?) which does the painfully work of automatically assigning the commits to the projects and creating different branches? I want to have something like this at the end:

Repo:

A---C---G<project A>
|\
| \
|  \
|   B---D<project B>
E---F<project C>


You're looking for git filter-branch using the --subdirectory-filter option.

Creating three branches for the three projects you want, and then running git filter-branch --subdirectory-filter projectX in those branches should give you the desired result.

You might also want to consider just using a repository per project. Once you've done the above, making new repositories, each containing one of the branches you created earlier as its master, will be trivial.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜