Project

General

Profile

Git Svn workflow and cheat sheet

NOTE: this page is still under construction - no guarantee for correctness ( not yet ).



External references and other links

reference on git/svn command equivalents

  • svn up => git svn rebase

  • svn commit => git svn dcommit (will commit latest commits in git to the svn repository

cloning and EDIT svn repo

Clone a svn sub-repository. It is important to specify the sub folders in trunk branches and tags!!

Here the subrepo drupal is used in the example:

 git svn clone -T trunk/drupal -t tags/drupal -b branches/drupal http://dev.e-taxonomy.eu/svn ./

create git ignore:

git-svn show-ignore > .gitignore

reverting via reset

whipe out all changes in working directory, and replace with HEAD revision

git reset --hard HEAD 

Merging and conflict resolution

resolving merge conflicts

 git mergetool
keep either file in merge conflicts

There’s two unmerged files here. According to the git checkout manpage, there’s a --theirs and --ours options on the command. The former will keep the version of the file that you merged in, and the other will keep the original one we had.

The following commands will keep the original file for index.html, and then use the merged in file only for _layouts/default.html.

git checkout --ours filename.c
git checkout --theirs filename.c
git add filename.c
git commit -m "using theirs"

Working on a svn branch for the first time

list remote branches

git branch -r

create a local branch and make it following the remote branch

git checkout -b <branchname> <remote branchname>

so usually it will be

git checkout -b <branchname> remotes/<branchname>

reintegrating an svn branch

git checkout <merge-to branch>; git merge --squash <merge-from branch>; git commit; git svn dcommit # --squash is key

delete or lock the branch afterwards!

lock an svn branch

not equivalent in git, thus you need to use svn for it.

checkout a fresh copy!!!:

svn co http://dev.e-taxonomy.eu/svn/branches/mybranch

lock in zsh with

svn lock <root>/**/*(.) 

in bash with

 find <root> -type f | xargs svn lock

delete the git remote branch:

git branch -D <branchname>
git branch -D -r <branchname>

Working wit a git branch

create a git branch

git checkout -b <branchname>

edit, commit, edit, commit, ...

keep the branch in sync with master (=remote/trunk)

git checkout master
git svn rebase
git checkout <branchname>
git rebase master

reintegrate the branch into master

git checkout master
git rebase <branchname>

commit to svn

git svn dcommit

Important: remove the local branch

git branch -D <branchname>
Add picture from clipboard (Maximum size: 40 MB)