Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to track two version of a project in one GIT repository?

Tags:

git

history

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.

like image 593
Kacper Avatar asked Nov 06 '22 17:11

Kacper


1 Answers

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.

like image 73
Milan Babuškov Avatar answered Nov 15 '22 05:11

Milan Babuškov