简体   繁体   中英

Git branching strategies and practices - different project based on the master branch project put into different branch instead of a new repository

Me and my colleague are developing code for embedded system and we keep it in git repository.

Aside from main Application project, we also needed to develop a Bootloader for the same device to be able to reprogram the application when necessary.

The main application consists of ~15 modules / C files, not counting the libraries provided by microcontroller vendor.
The Bootloader is made based on the Application project and in practice all the Application modules are removed, except modules for TCP stack, Ethernet configuration and other necessary things like clocks etc.

On top of this stripped-down Application project we added module doing the Bootloader jobs.

My colleague decided to keep this Bootloader in the same repository, but just on different branch.

In my opinion branches should be used only for the same project, as experiment, feature, release, stabilization branches etc.

Although today I cannot see any big technical or workflow issue to keep Bootloader in the same repo on different branch but I just don't find this solution elegant and would prefer to create separate repository for Bootloader.

Can you have multiple projects in one Git repository?
Maybe I am just way too pedantic and should not care that much about this and insist on creating a separate repository?

即使你认为这不是最好的做法(我倾向于同意),由于 git 的分布式特性,每个人的 repo 都是他们自己的......所以如果你的朋友/同事喜欢它那样......好吧,由他们决定......只要它不来咬你的追尾,我想就可以了。

Branches are made to isolate different development effort and are supposed to be merged back later.
They generally start from a common history.

But technically , you can put:

  • separate code in a branch (which will never be merged)
  • orphan branches : The first commit made on this new branch will have no parents and it will be the root of a new history totally disconnected from all the other branches and commits.

So yes, you can have multiple unrelated projects in one repository.
And with git worktree , you can clone once , and have multiple folders, one per branch/project.

So you can function that way, as long as each branch/project has not too much history/object (or the global clone could become cumbersome over time).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM