Having different versions of source code with some common and some different content in git

时间:2017-12-18 06:05:41

标签: android git version-control

I know this sounds a little bit odd but I'm really struggling with this situation and git branching is not the answer.

I have a situation that I need to keep my android source code in different versions. But the problem is some part of the code is common in these versions but some are not since they are files and edits based on different android market standards; they need to be different.

So I need to find a way to keep my source code in different versions and as I'm editing code, these common differences take effect in all versions but as I'm editing the different files and contents (Ones related to the markets) I need them to only effect and be added to their own version.

P.S: I cannot use git branching since I need to keep track of each and every version changes with commons and differences all the time and its not a logical approach cause it may cause problems.

P.S: I need to find a way to configure something like gitignore to approach this task and make git push commons and differences to their related versions.

P.S: If any other VCS or program helps to approach this I'd be glad to know.

2 个答案:

答案 0 :(得分:1)

Use different projects. Make your common parts a library, and then make different projects which include that library. Then you can have it in one repository. Alternatively, you can put them in different repositiories and use a git submodules to link between them.

答案 1 :(得分:0)

Git branching can meet your requirements.

Assume there are two market standards you need to work on, so you can manage your source code in three branches:

  • .EditBoking{ display: inline-block; height:auto; } branch: manage the versions for the common files. With common to match all the possible non common files so other branches merged in the .gitignore branch, the non common files won’t be tracked.
  • common branch: manage all the source code in market1 standard. And the non common files for market1 standard only managed in market1 branch.
  • market1 branch: manage all the source code in market2 standard. And the non common files for market2 standard only managed in market2 branch.

The workflow shoule be:

  • When changes made on market2 branch, if you want to update the common files in the different markets branches, you can merge common branch directly into the markets branches separately.
  • Develop and manage the versions of the non common files about market1 standard in common branch. If you changed the common files in market1 branch, you can update the version in common branch by merging market1 branch into market1 branch (the non common files won’t be added in common branch since it’s match in common).
  • Develop and manage the versions of the non common files about market2 standard in .gitignore branch. If you changed the common files in market2 branch, you can update the version in market2 branch by merging common branch into market2 branch.