Hello,
I'm relatively new to Git, but I want to give it a try (vs SVN and Bazaar)
Can anyone recommend me a workflow for a situation similar to the following:
- 1 SVN repo, with several projects
- 1 working copy "src"
The ideea is that in "src" I need to checkout project A or sometimes project B. Both projects have several branches.
For now, I have made 2 git clones of the SVN repo, one for each project. (I would have preffered --bare repos, but it does not work with "git svn clone")
Then, I made a git repo in "src", and git remote add projA ..a_repo_git
, "git remote add projB ..b_repo_git
".
Now, I can see both of them from "src" using "git remote", and I can see their branches with "git remote show projA"
And now the trouble..
- How can I get in "src" any of the branches in projA/projB ?
- How can I modify them, and then be able to push them back (first to the git_repos, or directly to the SVN repo)?
- Is this "workflow" ok, or do you have a better idea?
I did try in src: git checkout --track -b work_branch projA branch_in_A
and after some fiddleing with "fetch" I managed to get the things. But then, I had problems pushing it back to the a_repo_git
, and then to SVN. It was mostly trial and error.
I have to admit, I stil have problems with remote branches! (and I get lost when I have to use "origin local_branch:origin_branch
" or "origin origin_branch:local_branch
", or "origin origin_branch
" or "origin/origin_branch
"! Back to the Git manual for some more reading)
Thank you for any help.
Update: As someone proposed, there is no need for two extra repos that link each SVN project.
I've done the following:
mkdir src
cd src
git svn init --stdlayout --prefix=projA/ -RprojA file:///path/to/svn/repo/A
git svn init --stdlayout --prefix=projB/ -RprojB file:///path/to/svn/repo/B
vi .git/config -> update the svn-remote sections; I've left only the two with "projA" and "projB", but had to copy a line with fetch= from "svn" to "projA"
git svn fetch projA
git svn fetch projB
After this I could create a local branch with
git svn checkout -b my_branch projA/branch_name
(and "projA/branch_name" I think is the remote branch name + prefix, that appears with git branch -r)
So, basically now I have both svn projects linked in a single "workcopy" in "src", just like I've wanted. I can switch between the projects easily, in the same folder.
For now, I have not tried yet any push/pull, merge, or dcommit. I'll see into it later. Also, I want to investigate checkout using the "--track" option.
Thank you all who answered and commented here!