Skip to content

Instantly share code, notes, and snippets.

@jestinepaul
Created August 9, 2013 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jestinepaul/6191960 to your computer and use it in GitHub Desktop.
Save jestinepaul/6191960 to your computer and use it in GitHub Desktop.

A git workflow to use SVN server with Git from Windows through an intermediate Git in Linux

Initial Setup

[tom@my-linux-machine:~] $ git config --global receive.denycurrentbranch ignore

C:\>git config --global merge.commit no

Checkout

[tom@my-linux-machine:~/home/src] $ git svn clone -s -r28718:HEAD http://subversion.ny.mycompany.com/svn/repos/ABC/my-project
            
C:\dev> git clone tom@my-linux-machine:home/src/my-project

To Commit Locally

C:\dev\my-project> git add --patch MyClass.java
C:\dev\my-project> git commit -m "Fixed Bug"

To Push

C:\dev\my-project> git push

[tom@my-linux-machine:~/home/src] $ git reset --hard
[tom@my-linux-machine:~/home/src] $ git svn dcommit 

This takes all the commits you’ve made on top of the Subversion server code, does a Subversion commit for each, and then rewrites your local Git commit to include a unique identifier. This is important because it means that all the SHA-1 checksums for your commits change.

Because the SHA-1 changes after dcommit, pull back the same commit with the differnt SHA-1

C:\dev\my-project> git fetch
C:\dev\my-project> git reset origin/master

To Pull

[tom@my-linux-machine:~/home/src/my-project] $ git svn rebase
            
C:\dev\my-project> git pull --ff-only

If failed, rebase and resolve the conflicts

C:\dev\my-project> git stash
C:\dev\my-project> git pull --rebase
C:\dev\my-project> git stash pop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment