Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Basic Tasks 

Help

Git

SVN

git help______________

svn help{{______________

View content of remote repository (svn list)

Git

SVN

Browse on github______________

svn list http://svn.openmrs.org/openmrs/trunk/ (http://svn.openmrs.org/openmrs/trunk/*)______________

You can browse files in your local repository with git show or git ls-files.

...

Git

SVN

git clone git@github.com:username/openmrs-module-mymodule.git_____

svn checkout http://svn.openmrs.org/openmrs-modules/mymodule mymodule_______

If there is a remote branch that you want to add to your local repository, use the command:

git checkout --track origin/branchname

Get updates

git pull______________

Git

SVN

git fetch (updates your local copy of a remote branch)
or
git pull (goes a git fetch + git merge)

svn update______________

Compare working copy to head (what have I changed?)

Git

SVN

git diff______________

svn diff______________

Add new file(s)/folder(s) to version control

Git

SVN

git add myfile.txt______________

svn add myfile.txt______________

Delete file(s)/folder(s)

Git

SVN

rm myfile.txt
 
To remove from Git's index & add to Git ignore:
git rm --cached myfile.txt

To remove from Git's index (doesn't delete file):
git rm myfile.txt______________

svn rm myfile.txt______________

Ignore certain file(s)/folder(s)

Git

SVN

.gitignore______________

svn propset svn:ignore -F .svnignore .______________

Commit changes with comment (all or some of changes in working copy)

Git

SVN

git commit -m "comment"______________
git push
Note: It is better to use the command "git commit -a --signoff", which will open an editor using which you should write the commit comment.
This commit would be used as an email message and a subject and the format goes something like:
* First line is used as the subject
* Second line onwards is used as the body of the message
The --signoff option add the text:
"Signed-off-by: My Name <myemail@example.com>"
This signoff statement becomes part of the comment and will be used to track the changes done and also the copyright owners of the changes

svn commit -m "comment"______________

Get basic information about working copy (svn info)

Git

SVN

cat .git/config ______________

svn info______________

Revert changes (all or some changes in working copy)

Git

SVN

git reset --hard HEAD^______________

svn revert MyCode.java
or to revert the entire local copy:
svn revert --depth=infinity .______________

Create a patch (diff of working copy from head)

Git

SVN

git format-patch master --stdout > my_change.patch______________

svn xxx______________

Apply a patch

Git

SVN

git apply --stat my_change.patch______________

patch -p0 -i my_change.patch______________

Resolve conflicts

Git

SVN

git xxx______________

svn xxx______________

Create a branch (e.g., space for new module)

Git

SVN

git branch branchname
git checkout branchname
or, as a single step:
git checkout -b branchname______________

svn copy trunk branches/branchname
or to create an empty branch:
svn mkdir branches/branchname____________

Close a branch

Git

SVN

git branch -d branchname______________

svn del branches/branchname______________

Tag a release

Git

SVN

git tag -a tagname -m "Version tagname"______________

svn copy trunk tags/tagname______________

You can list out existing tags with git tag or search for a specific tag with git tag -l 1.9.*

...

Git

SVN

git remote set-url origin https://github.com/OpenMRSopenmrs/openmrs-module-newhome.git______________

svn switch https://svn.openmrs.org/openmrs-modules/newhome______________

Detach working copy

Git

SVN

git archive master | tar -x -C newlocation______________

svn export newlocation______________

Blame (show annotations / show who changed what line in what commit)

Git

SVN

git blame filename______________

svn blame filename______________

Show history

Git

SVN

git log______________

svn log______________

Switch to earlier revision

Git

SVN

git xxx______________

svn xxx______________

Correct/change old commit message

Git

SVN

git xxx______________

svn xxx______________

See Also