Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Thursday, May 12, 2011

Using GIT as SubVersion (SVN) client

Install git-svn in Ubuntu

All git-* commands are implemented in Ubuntu with the git command: 'git-svn' is in Ubuntu 'git svn', notice the space.

Checkout

Do a checkout from SVN with
git svn clone -s -r [revision] [SVN URL] [new directory]
The [SVN URL] is the root of your SVN repository, the remote directory that contains your trunk, tags and branches subdirectories. The [revision] is the SVN revision number from which you want to retrieve history from. You may want to limit the history, because it takes time to retrieve all of the history from SVN. Example:
git svn clone -s -r 198 https://nextaction.googlecode.com/svn nextaction

Update from SVN

To update your local files from SVN, execute:
git svn rebase
If the update refuses to pull the changes from SVN and displays a message with "needs update", you probably made changes that you have not commited yet. Apparently, you must commit your changes locally first

Commit to GIT

When you make changes to your local files, you can commit them with:
git commit -a -m "Commit message"

Commit to SVN

This will only commit changes to your local GIT repository, to commit (or "push" in the GIT jargon) to SVN, use:
git svn dcommit

Monday, January 3, 2011

Getting started with GIT

I recently started working on a new project and decided to try out the source repository GIT. As a long time user of CVS and Subversion (SVN), these distributed repositories take a little time getting used to.
As long as you use it yourself in a one man project, a distributed repository is almost the same as CVS and SVN. You check code out, make modifications and commit. The major difference is that you then "push" your commits to another repository, usually a remote server.

Create a local repository

To get started, after installing GIT, you can create a repository with the "init" command.
cd /path/to/repository
git init

Make modifications

Just like CVS and SVN, you can add/modify/delete files and commit them.
git add readme.txt
git commit -a -m "added readme text"
Note that this commit is stored locally, it is not committed to a central server.

Copy a repository

You can create a copy of a local repository with the "clone" command. This way you can locally make a branch.
cd /path/to/workspace
git clone /path/to/repository

Shareable repository

To create a sort of "central" repository like CVS or SVN, you can create a shareable repository with the "init" command. Do this on your server.
cd /path/to/repository
git init --bare --shared

Checkout with SSH

I use SSH to "checkout" from the remote repository, do this on your client.
cd /path/to/workspace
git clone ssh://myserver/path/to/repository
This makes a copy of the remote repository to my local workspace. Here I can make modifications and commit them. GIT will store your commit locally until you "push" this to the central repository.
git add readme.txt
git commit -a -m "added readme text"
git push origin master
This last command will update the remote repository with your commits.

See also