Using Git in Development, with SVN as Centralized Repo
Surprisingly SVN is still the commonly used version control system out there with some enterprises. However this should not hamper the developer from using all the cool features and workflows that GIT provides. GIT comes with built in support to migrate a svn repository to GIT and even better, it allows you to work with SVN as the centralized repo. Simpy put Git SVN bridge provides bidirectional operation between a Subversion repository and Git
The following are the commands and typical workflow structure that you would use most of the time working with SVN as centralized repo and having GIT as your local development repository.
For folks who are familiar with tortoiseSVN, the tortoiseGIT GUI tool will make you feel at home. Nonetheless you still need to know which command to use to get the job done.
- git svn clone http(s)://svn-repo-url
This command gets all the given svn repos trunk, branches,tags into the local git repository. Ensure your svn repo uses the common “trunk/branches/tags” layout. Else you can manually specify them. It will automatically create a directory based on the basename of the URL passed to it. From here you work with your local GIT repository as you normally would with any GIT repo.
- git svn dcommit
Commits all the git repo changes to svn remote repo
- git svn rebase
Gets all the latest contents from svn remote repo to local git repo
- When you do a git svn rebase and If there are conflicting changes between remote svn repo and local git repo, do the following:
a.) Merge the changes using any of your favorite editor.
b.) git add filename
c.) git rebase –continue
d.) git svn dcommit
- git status
show the working tree status
- git log
show commit logs
- git add [.|filename]
Add file contents to the index
- git commit -m “message”
Record changes to the local git repository