I am working on a svn project with two branches, lets call them
trunk
branches/foo
My idea is to clone the whole svn repository (telling git which folder are trunk, tags and branches), do the merge in git and then copy my merge to a svn working copy and commit the changes from svn.
In this workflow, will I be able to use gits merging power or will that only work for branches created with git itself?
git works perfectly fine with a svn repository on the other side, why not benefit from that? Certainly possible, and a fair move towards your colleagues, not to push unfinished changes. however there is one huge danger hidden in there: you will tend to make very few commits to the companies repository.
Git merge will combine multiple sequences of commits into one unified history. In the most frequent use cases, git merge is used to combine two branches.
If you merge a branch into trunk using "svn merge --reintegrate", you are recommended to delete the branch. If you want to do further development in that branch, you should "re-branch", effectively create a new branch with the same name, but rooted at the same revision as you merged the branch into trunk.
Create alias for checkout command:
git config alias.co checkout
Make sure that you local branches are up to date:
git co master # checkout branch that tracks subversion's trunk
git svn rebase
git co local/foo # checkout branch that tracks subversion's branches/foo
# It assumes that the branch is created with the command:
# `git co -b local/foo remotes/foo`
# And the repo was created with:
# `git svn clone --stdlayout SVN_REPO_URL`
git svn rebase
Merge branches:
# create new local branch based on `master`
git co master
git co -b merging_branch_foo
# merge, resolve conflicts, etc (pure git)
git merge local/foo
# rebase `merging_branch_foo` to linearize history for subversion
git rebase master # or `rebase -i`
# merge `merging_branch_foo` into `master`
git co master
git merge merging_branch_foo # --squash to create single commit
# commit changes to svn
git svn dcommit
# (optionally) delete `merging_branch_foo`
git branch -D merging_branch_foo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With