Skip to content

Instantly share code, notes, and snippets.

@ferventcoder
Created October 12, 2012 15:27
Show Gist options
  • Save ferventcoder/3879765 to your computer and use it in GitHub Desktop.
Save ferventcoder/3879765 to your computer and use it in GitHub Desktop.
Git SVN Setup
[alias]
spull = !git checkout master && git svn rebase
spush = !git checkout master && git svn dcommit
work = !git checkout work && git rebase master
prepwork = !git checkout work && git rebase master && git checkout master && git merge work
SET URL=%1
SET FOLDERNAME=%2
::http://stackoverflow.com/a/2348596/18475
git svn clone -r HEAD %URL% %FOLDERNAME%
::The above is a single branch or the trunk. If you want all of them, adjust your url accordingly and use this instead:
::git svn clone --stdlayout -r HEAD %URL% %FOLDERNAME%
$scriptDir = $(Split-Path -parent $MyInvocation.MyCommand.Definition)
function Install-NeededFor {
param(
[string] $packageName = ''
,[bool] $defaultAnswer = $true
)
if ($packageName -eq '') {return $false}
$yes = '6'
$no = '7'
$msgBoxTimeout='-1'
$defaultAnswerDisplay = 'Yes'
$buttonType = 0x4;
if (!$defaultAnswer) { $defaultAnswerDisplay = 'No'; $buttonType= 0x104;}
$answer = $msgBoxTimeout
try {
$timeout = 10
$question = "Do you need to install $($packageName)? Defaults to `'$defaultAnswerDisplay`' after $timeout seconds"
$msgBox = New-Object -ComObject WScript.Shell
$answer = $msgBox.Popup($question, $timeout, "Install $packageName", $buttonType)
}
catch {
}
if ($answer -eq $yes -or ($answer -eq $msgBoxTimeout -and $defaultAnswer -eq $true)) {
write-host "Installing $packageName"
return $true
}
write-host "Not installing $packageName"
return $false
}
#install chocolatey
if (Install-NeededFor 'chocolatey') {
iex ((new-object net.webclient).DownloadString("http://bit.ly/psChocInstall"))
}
if (Install-NeededFor 'gitextensions') {
cinst gitextensions
}
@ferventcoder
Copy link
Author

Workflow is:

  1. Keep master pristine with the svn branch you are working with
  2. Do all of your work in work
  3. When you are ready to pull in from your teammates, you call git spull. This will shift you over to master and pull all of the remote svn commits you don't have. You must not have anything uncommitted at this point.
  4. Then you call git work to have your teammates' commits applied to work before your changes.
  5. When you are ready to share work with your teammates, you follow the above steps for getting the changes into work. Then you call git prepwork to get the changes all into master. Call git spull one more time to be sure there are no more incoming commits. Then call git spush to push those changes up to your teammates and the build server.

@ferventcoder
Copy link
Author

This uses a shallow clone, which means is doesn't take forever. This is also meant to pull against a single branch or the trunk. If one wants to pull against all branches, and the trunk, one needs to call git svn clone --stdlayout -r HEAD URL FOLDERNAME

@ferventcoder
Copy link
Author

Also, a pretty neat tool out there is Git Standup - written by @AnthonyMastrean - you may need to adjust the author for git-svn checkins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment