如何在一个GIT存储库中跟踪两个版本的项目? [英] How to track two version of a project in one GIT repository?

查看:322
本文介绍了如何在一个GIT存储库中跟踪两个版本的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个本地git仓库中有两个版本的一个项目。 (V1 / V2) - >远程GIT(V1),远程GIT(V2),远程Git(V2) )



我在LOCAL GIT存储库中有一些文件,它们只应该放在REMOTE GIT(V1)上,其他的只能放在REMOTE GIT(V2)上。现在我提交完整的本地存储库到两个遥控器。
我只能将一些文件提交给REMOTE1吗?



我需要在一个存储库中同时存在两个版本的项目,但希望有一个可以分割的选项历史有点。我不认为任何分支都可以提供帮助,因为那样我就不得不对两个分支进行相同的更改。大部分代码中,90%的代码对于VER 1和VER 2是相同的。新代码通常对于两个版本都是相同的。

div>

分支正是你所需要的。使用Git进行分支很容易,而且速度非常快,所以除了几次击键外,您不会丢失任何东西。

您可以使用3个分支。创建一个通用分支,在这里你将处理两个叉子共有的东西,并在提交后合并到它们中。对于特定的东西,在其中一个分支中工作。



Git在文件系统上使用硬链接,因此分支在速度和使用空间。



最后,您可以随时选择推/拉哪个分支。


I have two versions of one project in one local git repository. I have to commit this repository into 2 remote repositories, one for each version;

LOCAL GIT(V1/V2) -> REMOTE GIT(V1), REMOTE GIT(V2)

I have some files in the LOCAL GIT repository which should only go to REMOTE GIT(V1) and other should only go to REMOTE GIT(V2). Now I commit full local repository to both remotes. Can I only commit some files to REMOTE1?

I need to have both version of the project in one repository, but would like to have an options to divide history a bit. I do not think that any branching can help as then I would have to make the same changes to both branches mostly. Most of the code, 90% of the code is the same for VER 1 and VER 2. New code is usually the same for both versions.

解决方案

Branching is exactly what you need. Branching is easy and very quick with Git, so you don't lose anything but a few more keystrokes.

You can use 3 branches. Create a "common" branch where you'll work on stuff common to both "forks" and merge into them after commits. For specific stuff, work in one of the branches.

Git uses hard links on the filesystem so branches are cheap both in terms of speed and used space.

Finally, you can always select which branch to push/pull.

这篇关于如何在一个GIT存储库中跟踪两个版本的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆