git branch - How do I incorporate a new source code updates while keeping my existing modifications in Git? -
so far, i've been using git , it's tolerable simple pushes , merges, got curve ball thrown @ me. developers of source code using released new version release source tree. several files have been changed , having difficulty figuring out how incorporate new source such can keep old version of code modifications 1 branch, version 1.0, , new version of code same modifications branch, version 2.0. i'm 1 working on project, don't care rewriting history if have too. ideally, able continue making modifications , have them apply both versions.
you can use submodule code of library using , able have 2 brunches in submodule (version 1.0 , version 2.0) , use master branch code. in such case when changes done able provide them both version 1.0 , version 2.0 switching branch in submodule
code example
cd /path/to/project/ mv lib /some/other/location/ git rm lib git commit -m'move lib submodule' cd /some/other/location/lib git init git add . git commit cd /path/to/project/ git submodule add /some/other/location/lib git commit -m'add submodule' cd /some/other/location/lib git checkout -b version2 modifications git commit -m'version2' cd /path/to/project/lib git fetch --all
now can switch between version1 , version2 by
cd /path/to/project/lib git checkout version2 git checkout master
another variant using rebase (not recommended). lets have muster branch version1 of lib
git checkout -b version2 apply changes in lib wich bring version 2. git commit git checkout master
now work in master (commit something). see master changes in version2 branch do
git checkout version2 git rebase master
Comments
Post a Comment