Comparing Git and Subversion commands

Here you can find a short and partial recap table, where I try to pair the most common Subversion and Git commands to help Subversion users to quickly shift their minds from Subversion to Git.

Subversion

Git

Creating a repository

svnadmin create <repo-name>
svnadmin import <project-folder>

git init <repo-name>
git add .
git commit –m "Initial commit"

Getting the whole repository for the first time

svn checkout <url>

git clone <url>

Inspecting local changes

svn status
svn diff | less

git status
git diff

Dealing with files (adding, removing, moving)

svn add <file>
svn rm <file>
svn mv <file>

git add <file>
git rm <file>
git mv <file>

Committing local changes

svn commit –m "<message>"

git commit –a –m "<message>"

Reviewing history

svn log | less
svn blame <file>

git log
git blame <file>

Branching and Tagging

svn copy <source> <branch-name> svn copy <source> <tag-name>

git branch <branch-name> 
git tag -a <tag-name>

Remember: in Subversion tags and branches represents physical copies of a source branch (the trunk, another branch or another tag), while in Git a tag is only a pointer to a particular commit.

Merging

(assuming the branch was created in revision 42 and you are inside a working copy of trunk)

svn merge -r 42:HEAD <branch>

git merge <branch>

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset