...
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
.
...
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 | SVN |
---|
git pull ______________ 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 xxxdiff ______________ | 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 . ______________ |
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 xxxreset --hard HEAD^ ______________ | svn xxxrevert 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 ______________ | svn xxx 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 xxx
|
---|
git branch branchname git checkout branchname or, as a single step: git checkout -b branchname ______________
| svn xxx __copy trunk branches/branchname or to create an empty branch: svn mkdir branches/branchname ____________
|
Close a branch
Git | SVN |
---|
git xxxbranch -d branchname ______________ | svn xxxdel branches/branchname ______________ |
Tag a release
Git | SVN |
---|
git xxxtag -a tagname -m "Version tagname" ______________ | svn xxxcopy trunk tags/tagname ______________ |
You can list out existing tags with git tag
or search for a specific tag with git tag -l 1.9.
*
Advanced Tasks
Switch working copy to new repository location
Detach working copy
Git | SVN |
---|
git xxxarchive master | tar -x -C newlocation ______________ | svn export newlocation ______________ |
Blame (show annotations / show who changed what line in what commit)
Git | SVN |
---|
git xxxblame filename ______________ | svn xxxblame 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