Good day!
In the article I will tell you how we work with svn through git and why we didnβt choose pure git.
Svn
Subversion is a centralized version control system. This is its main minus and its main plus :)
')
The advantage is that centralization makes it possible, for example, to number commits, since their order is known.
It also minimizes conflicts (although this can be argued about), because The current state of the repository is one and it is known to all.
In svn you can store multiple projects in one repository. In general, the svn repository intefrace is very similar to the file system, which provides a minimum entry threshold for those who have never worked with version control systems.
The main disadvantage is merge ... Those who often do merge with svn means understand what I mean.
This is slow (even meeeeeeeleeneno), requires a constant connection to the repository, and these svn-properties, which make it difficult to read the diff.
It would seem - the solution lies on the surface, you just need to change the version control system. In our case,
you canβt just go and go to git.
There are several reasons for this, and all of them are due to heritage. If we started development now, then most likely we would choose git. We have a repository for about six years, during which time we have created 129 projects in it, and the number of audits exceeded 88,000.
We use
trac as a bugtracker. It is now more than 10 thousand tickets. Many have links to commits confirming corrections. This rich heritage does not want to lose.
Also, svn has a plus - all projects are in the same repository. Trac thinks that we have one project, which greatly facilitates working with him.
In other words, giving up svn is too expensive for us, but merzh ...
Decision
Let svn be inside the repository, but everyone will work with it through git. Let's do it!
- Install git and git-svn. The installation method depends on your operating system. In my case it comes down to a simple set of commands:
apt-get update && apt-get install subversion git git-svn
- Create a nice to use ~ / .gitconfig
[user] email = e.kokovikhin@co.wapstart.ru name = Evgeniy V. Kokovikhin [core] editor = vim [alias] co = checkout br = branch ci = commit st = status di = diff
- Clone the svn repository:
cd /var/www/project.wapstart/ mkdir project && cd project
The last team will take tangible time. On our repository - hours 4.
--stdlayout seems to tell us that the project layout is standard:
project βββ trunk βββ branches β βββ dovgFeature β βββ dovgAnotheFeature βββ tags βββ 3.0.1 βββ 3.0.2
Actually everything.
The trunk is now called master, all other branches are named as usual.
Work with brunches:
git branch -r # git checkout -b dovgBranch dovgBranch # dovgBranch dovgBranch git branch # β
For example:
dovg@marvin ~/job/oemdesign/www/plus1.wapstart.loc/plus1 $ git branch dovgUnique experimental * master moderation production referals targetingCountry uniqueCookie uniqueSession ---------
And how to work with it now?
- Work with svn
git svn rebase # ( ) git svn fetch # git svn dcommit # svn git svn branch <branch-name> # :) git svn help branch git svn info # svn,
- Merge. For this, we did it all.
git merge --log master # .
For merge to master (trunk)
git checkout master git merge --no-ff <branch-name>
Merzy pass quickly, because do not require a remote repository. No one is afraid of them anymore.
- Git basics
git diff β git commit β «» git commit -a β , , git add β . svn. svn , git , git commit -a git reset
Finally a small FAQ:
- Make brunch and switch to it: git svn branch ticket-666 && git svn fetch && git co -b ticket-666 ticket-666
- Transfer brunch to master: git co ticket-666 && git merge --log --no-ff master && git svn dcommit && git co master && git merge --log --no-ff ticket-666 && git svn dcommit
- Pass the brunch to the test (update from the wizard and commit): git co ticket-666 && git merge --log --no-ff master && git svn dcommit
Update periodically repository: git svn fetch
Instead of conclusion
For a long time, this article has hung in the
Wapstart internal wiki. It seemed to me that it could be useful to the community. The result is in front of you. ;)