Skip to content

Instantly share code, notes, and snippets.

@andylind
Last active October 4, 2015 14:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andylind/2655799 to your computer and use it in GitHub Desktop.
Save andylind/2655799 to your computer and use it in GitHub Desktop.
workflow for using git with svn
##############################
# Setup
##############################
# create local repo
git svn init -s http://url-of-repo
git svn fetch
git svn rebase
##############################
# Simple Workflow
##############################
# get updates from svn
git svn rebase
# make some changes and commit locally
git commit -a -m "made some changes"
# commit changes to svn
git svn dcommit
##############################
# Local Branching Workflow
##############################
# work on a local branch or branches
git checkout -b myfeature
# make some changes and commit
git commit -a -m "made some changes"
# switch to master and rebase changes
git checkout master
git rebase myfeature
git svn rebase
# see changed files between local and svn trunk
git diff --name-only remotes/trunk
# commit changes to svn
git svn dcommit
##############################
# Stash Changes
##############################
# save changes in the workspace to the stash
git stash save 'some name for what is saved'
# do some work
# then decide to go back to what is in the stash
# apply the top stash’s changes to the workspace
git stash pop
# check to see what stashes exist
git stash list
# see what files are changed in the top stash
git stash show
# clear all items from the stash
git stash clear
##############################
# Dealing With Problems
##############################
# see all changes between local and svn trunk
git diff remotes/trunk
# reset to a specific revision
git reset --hard HEAD
# delete a local branch
git branch -d mylocalbranch
# view decorated log
git log --decorate --graph –oneline
# change the comment on the last local commit
git commit --amend -m "New commit message"
# combine the last 3 commits
git rebase -i HEAD~3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment