In git, I have a master branch, where I am developing my application.
Along with the application I need to develop a demo version of it.
I thought about creating a separate branch for demo that would never be merged into the master.
The main problem is that I expect to develop some features that would be common both for application and demo.
What would be the right strategy to deal with that problem? Is there any way to “share” commits in git?
If your demo version can’t be defined using configuration, then yes you should use a branch.
The fact that you won’t merge it into master doesn’t prevent your from merging from master (or other branchs) into your demo, so you can propagate your new features into your demo branch without difficulty.
The way to “share commits” is to
1) commit into master or into a branch dedicated to your feature
2) go into your demo branch (
git checkout demo)3) import the code from your other branch (this won’t erase what makes your demo branch special) using
git merge masterorgit merge myfeaturebranchA merge doesn’t mean your destination branch is identical afterwards to the source branch.