subversion to git migration

19
Case Study:

Upload: manish-chakravarty

Post on 29-Nov-2014

3.664 views

Category:

Documents


2 download

DESCRIPTION

A simple presentation where I discuss moving from SVN to Git for source code control management for a typical team

TRANSCRIPT

Page 1: Subversion to Git Migration

Case Study:

Page 2: Subversion to Git Migration

Introduction Distributed Source Code Control

Git’s Features

Benefits of Git over SVN

SVN to Git Migration Migrating from SVN to Git

How to use Git with SVN Conclusion Sources

Page 3: Subversion to Git Migration

Section I

Page 4: Subversion to Git Migration
Page 5: Subversion to Git Migration

Repositories URL Revisions

Commits Commands Colors

Visualize

Page 6: Subversion to Git Migration

With Subversion, for each project there is a single repository at some detached central place where all the history is and which you checkout and commit into.

Git works differently, each copy of the project tree (we call that the working copy) carries its own repository around (in the .git subdirectory in the project tree root). So you can have local and remote branches.

You can also have a so-called bare repository which is not attached to a working copy; that is useful especially when you want to publish your repository

Page 7: Subversion to Git Migration

In Subversion the URL identifies the location of the repository and the path inside the repository, so you organize the layout of the repository and its meaning.

Normally you would have trunk/, branches/ and tags/ directories.

In Git the URL is just the location of the repository, and it always contains branches and tags.

One of the branches is the default (normally named master).

Page 8: Subversion to Git Migration

Subversion identifies revisions with ids of decimal numbers growing monotonically which are typically small (although they can get quickly to hundreds of thousands for large projects). That is impractical in distributed systems like Git.

Git identifies revisions with SHA1 ids, which are long 160-bit numbers written in hexadecimal. It may look scary at first, but in practice it is not a big hurdle - you can refer to the latest revision by HEAD, its parent as HEAD^ and its parent as HEAD^^ = HEAD~2 (you can go on adding carrets

Page 9: Subversion to Git Migration

Each commit has an author and a committer field, which record who and when created the change and who committed it

Git is designed to work well with patches coming by mail - in that case, the author and the committer will be different.

Git will try to guess your realname and email, but especially with email it is likely to get it wrong. You can check it using git config -l and set them with: git config --global user.name "Your Name Comes Here"

git config --global [email protected]

Page 10: Subversion to Git Migration

The Git commands are in the form “gitcommand <command_name>”.

Eg- “git commit …. “

You can interchangeably use the git-command form as well

Eg “git-commit ….”

Page 11: Subversion to Git Migration

Git can produce colorful output for commands

Colors are disabled by default

Page 12: Subversion to Git Migration

Watch your repository using the gitkrepository viewer as you go.

Page 13: Subversion to Git Migration

SVN Git

Page 14: Subversion to Git Migration

Section II

Page 15: Subversion to Git Migration

• git svn clone https://svn.foo.com/svn/proj --trunk=trunk --branches=branches --tags=tags

Import your SVN repo into Git

• git checkout -b work trunk

Make your own Git branch

• git add <filename>

Add the files you changed

• git commit

Commit

• git svn dcommit

Want to sync with master SVN?

Page 16: Subversion to Git Migration

Why would we want this? Since Git is a distributed revision control system

(while svn is a centralized one) you can perform commits, brances and merges on your local working dir.

When you want, you will be able to “push” your changes back to the central SVN server

What are the advantages of this approach? No downtime. Smooth migration

Existing system can run as-is while hooks are being written to integrate git into the system.

Page 17: Subversion to Git Migration

Install• install git and git-svn

Create• create the working dir

Init

• init your git working dir:

• cd <workdir> && git-svn init http://your_repo

Find

• Find a commit regarding the project

• the command git-log will show project’s history starting from this revision

Fetch

• Perform the command git-svn fetch –rREVISION

• Where REVISION is the number obtained before.

Update• Update your working dir: git-svn rebase

Commit• You can commit your changes using git-svn dcommit

Page 18: Subversion to Git Migration

Sometimes, you may experience some problem when synchronizing with the main development tree.

In fact you have to commit all local modifications (using the git-commit command) before invoking git-svn rebase.

Sometimes it isn’t reasonable since your changes are not yet ready to be committed.

git has a native solution also for this problem, just follow these steps: put aside your changes using the command: git-stash update your working copy using: git-svn rebase as usual take back your changes typing: git-stash apply clear the stash by typing: git-stash clear

After the first step all your uncommitted changes will disappear from the working copy, so you’ll be able to perform the rebase command without problems.

For further informations read git-stash man page.

Page 19: Subversion to Git Migration

A DSCM gives a lot of flexibility when development is happening across various team.

Care needs to be taken while doing an SVN git migration.

SVN & git should be used simultaneously until the team is confident about git.