Using git with SVN repo
- initialize the git repo.  - mkdir git-repo
- cd git-repo
- git init
 
- init git-svn repo. it will create a section [svn-remote “svn”] into file git-repo/.git/config      - for local svn, use the following command or use can manually add the section to git-repo/.git/config          -              git svn init file:///cygdrive/d/work/000-repos -T projectName/trunk -b projectName/branches -t projectName/tags will create the following section:
 - The colors in purple is must match to your remote SVN server, and colors in fuchsia means the name of remote branch will be created in git repo.            
 
 [svn-remote "svn"]
 url = file:///cygdrive/d/work/000-repos
 fetch = projectName/trunk:refs/remotes/trunk
 branches = projectName/branches/*:refs/remotes/*
 tags = projectName/tags/*:refs/remotes/tags/*
-              
- for remote svn, use the following command          - git svn init https://remote.com/svn -T projectName/trunk -b projectName/branches -t projectName/tags
 
- [option] add --prefix projectName/ can add the projectName to refs if you want to access multiple projects          - git svn init https://remote.com/svn --prefix projectName/ -T projectName/trunk -b projectName/branches -t projectName/tags
 [svn-remote "svn"] 
 url = file:///cygdrive/w/enreach/000-repos
 fetch = projectName/trunk:refs/remotes/projectName/trunk
 branches = projectName/branches/*:refs/remotes/projectName/*
 tags = projectName/tags/*:refs/remotes/projectName/tags/*
 
- for local svn, use the following command or use can manually add the section to git-repo/.git/config          
- fetch the revision history from svn      - git svn fetch
 
- check the remote branch(SVN) after fetch is done.      - git branch –r          rel1.1 
 bug-fix
 trunk
 
- git branch –r          
- create a local branch for the remote SVN branch you want to work on      - git checkout master
- git checkout –b git-bug-fix bugfix
- git svn rebase
 
- clone another local git to work and keep the git-repo to sync with the remote SVN server.      - git checkout git-bug-fix
- git clone . ../git-local
 
- work on the git-local,      - cd ../git-local
- edit some files;
- git commit –a;
- edit some files;
- git commit –a
- git status# On branch git-bug-fix         
 # Your branch is ahead of 'origin/git-bug-fix' by 2 commits.
 
- now if you want to push the changes to remote svn server.      - cd ../git-repo
- git checkout git-bug-fix
- git svn rebase
- git pull ../git-local (this will get all commits in to branch git-bug-fix, keep all commits individual)
- if you want to merge all small commits into one, use the following command          - git pull --squash ../git-local (this will get all commits into branch git-bug-fix as one commit)
 
- git status          windows/config.h: needs merge 
 # On branch git-bug-fix
 # Changes to be committed:
 # (use "git reset HEAD <file>..." to unstage)
 #
 # modified: test/test.c
 #
 # Changed but not updated:
 # (use "git add <file>..." to update what will be committed)
 # (use "git checkout -- <file>..." to discard changes in working directory)
 #
 # unmerged: windows/config.h
 #
- if there has any conflict like above, then fix it and use          - git add windows/config.h
 
- git commit –m “blah, blah…”
- git svn dcommit
 


0 Comments:
Post a Comment
<< Home