I'm working on a new project that I plan to keep in a git repository. I know how I would do this in CVS, but I'm a bit new to git and could use some suggestions.
我正在开发一个我计划保留在git存储库中的新项目。我知道如何在CVS中做到这一点,但我对git有点新意,可以使用一些建议。
The project is firmware for two embedded devices that talk to each other and are packaged as a pair. For both devices there is a production variant and a manufacturing variant of the code. Both device projects have a number of sub/sibling projects for exercising various bits of the hardware (blink the LEDs, etc), or hardware related bits of code (drivers, etc). Most of the code is common across everything.
该项目是两个嵌入式设备的固件,它们相互通信并作为一对打包。对于这两种设备,存在生产变体和代码的制造变体。两个设备项目都有许多子/兄弟项目,用于执行硬件的各种位(闪烁LED等)或硬件相关的代码位(驱动程序等)。大多数代码在所有内容中都很常见。
I also have a requirement to be able to rev the production and manufacturing firmware independently of each other to prevent a change to one from sending the other back through verification.
我还要求能够相互独立地修改生产和制造固件,以防止更改为通过验证发送另一个固件。
Below is my existing directory layout. It grew organically and was largely laid down before I knew I would be using git. I'm not averse to reorganizing the whole thing if there's a better way to do it.
下面是我现有的目录布局。它有机地增长,并且在我知道我将使用git之前基本上已经奠定了。如果有更好的方法,我不反对重组整个事情。
- ProjectRoot
- include
- src
- DeviceA
- production
- manufacturing
- blink
- buttons
- ...
- DeviceB
- production
- manufacturing
- blink
- buttons
- ...
DeviceA生产制造闪烁按钮......
DeviceB生产制造闪烁按钮......
ProjectRoot包括src DeviceA生产制造闪烁按钮...... DeviceB生产制造闪烁按钮......
I'm tempted to put production and manufacturing on branches, but I typically work on both in a given day and git only allows one branch to be active at a time. And then I wouldn't know what to do with blink, buttons, etc because they're not really manufacturing or production. Suggestions?
我很想将生产和制造放在分支机构上,但我通常在某一天工作,git只允许一个分支一次处于活动状态。然后我不知道如何处理闪烁,按钮等因为它们不是真正的制造或生产。建议?
Clarifications:
-
The manufacturing version of the code is used on the manufacturing line to test the hardware. The production code is loaded after the hardware passes the test station and is what's shipped to the customer. The two are at least 75% similar, but they need to be independent so I can fix a bug in the production code without having to stop the manufacturing line.
在生产线上使用代码的制造版本来测试硬件。生产代码在硬件通过测试站后加载,并运送给客户。这两者至少有75%相似,但它们需要独立,因此我可以修复生产代码中的错误而无需停止生产线。
-
Because DeviceA and DeviceB are a pair, both code sets are tagged and released at the same time with the same release version number.
由于DeviceA和DeviceB是一对,因此两个代码集都使用相同的发行版本号进行标记和同时发布。
2 个解决方案
#1
I used git to manage hardware/software codesigns, so I may have some useful advice to give.
我使用git来管理硬件/软件代码,所以我可能会给出一些有用的建议。
As a rule of thumb, if you have parts of the design that can interoperate with each other regardless of the revision you're working on, you're better off making separate git repositories for these.
根据经验,如果您拥有可以互相操作的部分设计而不管您正在进行哪些修订,那么最好为这些修改创建单独的git存储库。
To give an example, you want your driver to sit in a separate repository from your hardware design. This is because the interface between software and hardware is very clear-cut and is a natural seam to decompose by. Furthermore, the same driver version will apply to a range of design stages of your device.
举个例子,您希望您的驱动程序位于与硬件设计不同的存储库中。这是因为软件和硬件之间的界面非常清晰,并且是分解的天然接缝。此外,相同的驱动程序版本将适用于您设备的一系列设计阶段。
I am not sure what you mean by production and manufacturing editions of the design. If you want to decouple the development and stable versions, you should be fine with having separate branches for these.
我不确定您的设计的生产和制造版本是什么意思。如果你想要分离开发版本和稳定版本,你可以为这些版本分别设置分支。
Branching and merging in git is as cheap as you can get, and switching between branches is lightning fast; so there's no penalty for having branches. It is also fairly easy to cherry-pick compatible changes between branches. The approach that you usually see in software world (branches for releases, plus one HEAD) works fairly well.
git中的分支和合并就像你能得到的一样便宜,并且在分支之间切换是快速的;因此,分支机构不会受到惩罚。在分支之间挑选兼容的变化也相当容易。您通常在软件世界中看到的方法(发布的分支,加上一个HEAD)运行得相当好。
You should probably keep the demo/test modules (blinkers etc) together with the modules they are supposed to demo/test. This is because the demo coupling interfaces are often change-prone. This way you will have to keep the demo code in sync with the actual devices, which should help design stability in the long run.
您应该将演示/测试模块(闪光灯等)与他们应该演示/测试的模块放在一起。这是因为演示耦合接口通常易于更改。这样您就必须使演示代码与实际设备保持同步,从长远来看,这有助于设计稳定性。
As a side note, in the FPGA world, you are usually prototyping on a large device, and productionizing on a restricted device. This way, your modules end up having two varieties that are developed independently. You will probably want to keep these varieties in separate repositories, because they are, in effect, different entities. In this case, the code that is shared between the two (there's always some portable code you can reuse) can live in a separate repo, and be a separate library. Especially if the code size justifies it.
作为旁注,在FPGA领域,您通常在大型设备上进行原型设计,并在受限设备上进行生产。这样,您的模块最终会有两个独立开发的变体。您可能希望将这些变量保存在单独的存储库中,因为它们实际上是不同的实体。在这种情况下,两者之间共享的代码(总有一些可以重用的可移植代码)可以存在于一个单独的仓库中,并且是一个单独的库。特别是如果代码大小合理的话。
You can then bind all the mentioned modules together by using git submodules.
然后,您可以使用git子模块将所有提到的模块绑定在一起。
#2
I think you could use sub-modules. I am not 100% sure how this works, but you can create a git repo for you common code (say LED and user interface, or even one repo for each), and include a copy of this repo as a submodule of your repo for A, and another copy as a submodule of the repo for B.
我想你可以使用子模块。我不是100%确定这是如何工作的,但你可以为你的公共代码创建一个git repo(比如LED和用户界面,甚至每个代码都有一个repo),并且包含这个repo的副本作为你的repo的子模块A,另一个副本作为B的回购的子模块。
If you want to make changes to the common part, do that on the unit your currently working on. When you're done, push the changes to the submodules of the other product. You could also have the repo for the common part somewhere else if that feels more comfortable.
如果要对公共部件进行更改,请在当前正在处理的设备上进行更改。完成后,将更改推送到其他产品的子模块。如果感觉更舒服,你也可以在其他地方使用共同部分的回购。
To sum up: have your reusable code in separate repos, so you CAN reuse it.
总结一下:将您的可重用代码放在单独的存储库中,以便您可以重复使用它。
I'm no king of submodules, but I will soon need to do the same thing as you're doing. So I'm interested in how you will get it working.
我不是子模块之王,但我很快就需要做你正在做的事情。所以我对你将如何运作感兴趣。
#1
I used git to manage hardware/software codesigns, so I may have some useful advice to give.
我使用git来管理硬件/软件代码,所以我可能会给出一些有用的建议。
As a rule of thumb, if you have parts of the design that can interoperate with each other regardless of the revision you're working on, you're better off making separate git repositories for these.
根据经验,如果您拥有可以互相操作的部分设计而不管您正在进行哪些修订,那么最好为这些修改创建单独的git存储库。
To give an example, you want your driver to sit in a separate repository from your hardware design. This is because the interface between software and hardware is very clear-cut and is a natural seam to decompose by. Furthermore, the same driver version will apply to a range of design stages of your device.
举个例子,您希望您的驱动程序位于与硬件设计不同的存储库中。这是因为软件和硬件之间的界面非常清晰,并且是分解的天然接缝。此外,相同的驱动程序版本将适用于您设备的一系列设计阶段。
I am not sure what you mean by production and manufacturing editions of the design. If you want to decouple the development and stable versions, you should be fine with having separate branches for these.
我不确定您的设计的生产和制造版本是什么意思。如果你想要分离开发版本和稳定版本,你可以为这些版本分别设置分支。
Branching and merging in git is as cheap as you can get, and switching between branches is lightning fast; so there's no penalty for having branches. It is also fairly easy to cherry-pick compatible changes between branches. The approach that you usually see in software world (branches for releases, plus one HEAD) works fairly well.
git中的分支和合并就像你能得到的一样便宜,并且在分支之间切换是快速的;因此,分支机构不会受到惩罚。在分支之间挑选兼容的变化也相当容易。您通常在软件世界中看到的方法(发布的分支,加上一个HEAD)运行得相当好。
You should probably keep the demo/test modules (blinkers etc) together with the modules they are supposed to demo/test. This is because the demo coupling interfaces are often change-prone. This way you will have to keep the demo code in sync with the actual devices, which should help design stability in the long run.
您应该将演示/测试模块(闪光灯等)与他们应该演示/测试的模块放在一起。这是因为演示耦合接口通常易于更改。这样您就必须使演示代码与实际设备保持同步,从长远来看,这有助于设计稳定性。
As a side note, in the FPGA world, you are usually prototyping on a large device, and productionizing on a restricted device. This way, your modules end up having two varieties that are developed independently. You will probably want to keep these varieties in separate repositories, because they are, in effect, different entities. In this case, the code that is shared between the two (there's always some portable code you can reuse) can live in a separate repo, and be a separate library. Especially if the code size justifies it.
作为旁注,在FPGA领域,您通常在大型设备上进行原型设计,并在受限设备上进行生产。这样,您的模块最终会有两个独立开发的变体。您可能希望将这些变量保存在单独的存储库中,因为它们实际上是不同的实体。在这种情况下,两者之间共享的代码(总有一些可以重用的可移植代码)可以存在于一个单独的仓库中,并且是一个单独的库。特别是如果代码大小合理的话。
You can then bind all the mentioned modules together by using git submodules.
然后,您可以使用git子模块将所有提到的模块绑定在一起。
#2
I think you could use sub-modules. I am not 100% sure how this works, but you can create a git repo for you common code (say LED and user interface, or even one repo for each), and include a copy of this repo as a submodule of your repo for A, and another copy as a submodule of the repo for B.
我想你可以使用子模块。我不是100%确定这是如何工作的,但你可以为你的公共代码创建一个git repo(比如LED和用户界面,甚至每个代码都有一个repo),并且包含这个repo的副本作为你的repo的子模块A,另一个副本作为B的回购的子模块。
If you want to make changes to the common part, do that on the unit your currently working on. When you're done, push the changes to the submodules of the other product. You could also have the repo for the common part somewhere else if that feels more comfortable.
如果要对公共部件进行更改,请在当前正在处理的设备上进行更改。完成后,将更改推送到其他产品的子模块。如果感觉更舒服,你也可以在其他地方使用共同部分的回购。
To sum up: have your reusable code in separate repos, so you CAN reuse it.
总结一下:将您的可重用代码放在单独的存储库中,以便您可以重复使用它。
I'm no king of submodules, but I will soon need to do the same thing as you're doing. So I'm interested in how you will get it working.
我不是子模块之王,但我很快就需要做你正在做的事情。所以我对你将如何运作感兴趣。