Git experimental branch or separate experimental repository?

I'm developing an Android application and have been using Git throughout the entire development cycle. I've now come to a point where I would like to build and release experimental features for people to try out and install, while still having the original, stable, application installed on their devices.

Now, this means I need to use a different package-name, which changes a few fundamental files in the development-project. I'd also like to have a separate icon to clearly differentiate the applications.

I'm not used to Git enough to know which way to take here: Should I create an experimental branch which I branch off of when I want to make some lab-work or do I keep this experimental work as a separate git-repo?

I have a couple of problems with the actual flow of going either way.

  • If I make an experimental branch, I don't want to (mistakenly?) merge the changes of the package names and the clearly separating experimental details with the master branch; I only want to merge the working parts of the code, without the extra added modification.
  • If I make a separate repo, how do I merge the changes from experimental repo to master repo, considering the same wish to not replace ie. package names and icons?

  • That's exactly what branches are for. The one limitation is that git really sees commits, not files. So you typically would merge back one or a few commits from a different branch into master using the cherry-pick command.

    git branch branchx
    git checkout branchx
    ... do work, commit (into branchx), repeat...
    git checkout master   # return to master
    git log branchx  # to find out the ID of the commit to merge back
    git cherry-pick <commit ID from branchx>
    

    That's the preferred approach. This implies that you should keep this in mind while working in your experimental branch. Your commits should be small enough to include only the files that are involved in a fix/feature.

    Alternative, you can pick some files to merge back using

    # from branch master do
    git checkout branchx file1 file2 file3
    

    See this related answer How do you merge selective files with git-merge?


    I would certainly go for a branch. You would have to excercise some discipline in commits, make them small enough that you can cherry-pick only the parts you need and leave the others. But I don't think that's a problem, certainly not in comparison to merging changes between two separate repositories.

    链接地址: http://www.djcxy.com/p/27120.html

    上一篇: git标签命令的标志?

    下一篇: Git实验分支或单独的实验库?