0% found this document useful (0 votes)
3 views

Git for Subversion Users Cheatsheet

This document provides a comparison between Git and Subversion (SVN) for users transitioning from SVN to Git. It outlines key operations such as creating repositories, committing changes, inspecting history, branching, tagging, and merging, highlighting the differences in commands and workflows between the two systems. The document emphasizes Git's advantages, including local repositories, faster operations, and more flexible branching and merging capabilities.

Uploaded by

Misael García
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Git for Subversion Users Cheatsheet

This document provides a comparison between Git and Subversion (SVN) for users transitioning from SVN to Git. It outlines key operations such as creating repositories, committing changes, inspecting history, branching, tagging, and merging, highlighting the differences in commands and workflows between the two systems. The document emphasizes Git's advantages, including local repositories, faster operations, and more flexible branching and merging capabilities.

Uploaded by

Misael García
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

GIT FOR SUBVERSION USERS

presented by
TOWER — the best Git client for Mac and Windows

Creating a New Repository Committing Local Changes


With git init, an empty repository is created in the current folder of Inspecting your current local changes is very similar in both systems.
your local hard drive. The git add command then marks the current
contents of your project directory for the next (and in this case: SUBVERSION
$ svn status
first) commit. $ svn diff | less

SUBVERSION GIT
$ svnadmin create /path/to/repo $ git status
$ svn import /path/to/local/project http:// $ git diff
example.com/svn/ trunk -m "Initial import"

In case you’ve created new files or deleted old ones, you should
GIT
$ git init tell Git with the git add and git rm commands. You’ll be pleased to
$ git add . hear that it’s safe to inform Git after deleting or moving a file or
$ git commit -m "Initial commit"
even a folder. This means you should feel free to delete or move
even complete directory structures in your favorite editor, IDE,
or file browser and later confirm the action with the add and rm|
Cloning a Remote Repository commands.

Getting a copy of the project from a remote server seems almost SUBVERSION
$ svn add <file>
identical. However, after performing git clone, you have a full-
$ svn rm <file>
blown local repository on your machine, not just a working copy.
GIT
$ git add <file>
SUBVERSION $ git rm <file>
$ svn checkout
svn+ssh://[email protected]/svn/trunk
In its simplest form, committing can feel just like in Subversion.
GIT With the -a option, you tell Git to simply add all current local
$ git clone
changes to the commit.
ssh://[email protected]/path/to/git-repo.git

SUBVERSION
$ svn commit -m "message"

Inspecting History $ git commit -a -m "message"


GIT
To inspect historic commits, both systems use the log command.
Keep in mind, however, that gitlog doesn’t need to ask the remote Although short-circuiting Git’s staging area like this can make
server for data: your project’s history is already at hand, saved in sense, you’ll quickly begin to love it once you understand how
your local repository. valuable it is:

SUBVERSION You can add selected files to the staging area and even limit this to
$ svn log | less
certain parts (or even lines) of a file by specifying the -p option. This
GIT allows you to craft your commits in a very granular way and only
$ git log add changes that belong to the same topic in a single commit.

GIT
$ git add <file1> <file2>
$ git add -p <file3>

30-day free trial available at


www.git-tower.com The best Git Client for Mac & Windows
GIT FOR SUBVERSION USERS

Branching & Tagging Everything else is taken care of for you: you can merge two
branches as often as you like, don’t have to specify any revisions
In contrast to Subversion, Git doesn’t use directories to manage and can expect the operation to be blazingly fast if you’re merging
branches. Instead, it uses a more powerful and lightweight approach. two local branches.
As you might have already noticed, the git status command also
If a merge conflict should occur, Git will already update the rest
informs you about which branch you are currently working on. And
of the working copy to the new state. After resolving a conflicted
in Git, you are always working on a branch!
file, you can mark it using the git add command.
SVN
$ svn copy http://example.com/svn/trunk/ SUBVERSION
$ svn resolved <file>
http://example.com/svn/branches/<new-branch>

GIT GIT
$ git add <file>
$ git branch <new-branch>

To switch to a different branch and make it active (then also


referred to as the HEAD branch), the git checkout command is Sharing & Collaborating
used. Because switching can take some time in Subversion, it’s
To download & integrate new changes from a remote server, you
not unusual to instead have multiple working copies on your disk.
use the git pull command.
In Git, this would be extremely uncommon: since operations are
very fast, you only keep a single local repository on your disk. SUBVERSION
$ svn update
SUBVERSION
$ svn switch GIT
http://example.com/svn/branches/<branch> $ git pull

GIT If you only want to download & inspect remote changes (before
$ git checkout <branch>
integrating them), you can use git fetch. Later, you can integrate
the downloaded changes via git merge.
Listing all available local branches just requires the git branch|
command without further arguments. GIT
$ git fetch
SVN
$ svn list http://example.com/svn/branches/
In Subversion, data is automatically uploaded to the central server
GIT when committing it. In Git, however, this is a separate step. This
$ git branch
means you can decide for yourself if and when you want to share
your work. Once you’re ready, the git push command will upload
Creating tags is just as quick & cheap as creating branches. the changes from your currently active branch to the remote
branch you specify.
SVN
$ svn copy http://example.com/svn/trunk/
http://example.com/svn/tags/<tag-name> GIT
$ git push <remote> <branch>

GIT
$ git tag -a <tag-name>
Your teammates, too, will publish their work like this on a remote
(with the git push command). If you want to start working on such
a branch, you need to create your own local copy of it. You can
Merging Changes use the git checkout command with the --track option to do just
that: create a local version of the specified remote branch. You can
Like in newer versions of SVN, you only need to provide the branch later share the additional commits you’ve made at any time with
you want to integrate to the git merge command. the git push command, again.

SUBVERSION SUBVERSION
$ svn merge -r REV1:REV2 $ svn switch
http://example.com/svn/branches/<other-branch> http://example.com/svn/branches/<branch>
$ svn merge (or in newer SVN versions)
http://example.com/svn/branches/<other-branch> GIT
$ git checkout --track <remote>/<branch>

GIT
$ git merge <other-branch>

30-day free trial available at


www.git-tower.com The best Git Client for Mac & Windows

You might also like