Last active
August 29, 2015 14:24
-
-
Save tkirill/7c14331de4da814069af to your computer and use it in GitHub Desktop.
Git test rig for http://stackoverflow.com/q/31026942/458723
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For http://stackoverflow.com/q/31026942/458723 | |
function Clean-TestRepos { | |
if (Test-Path test-repo) { | |
rm -Force -Recurse test-repo | |
} | |
if (Test-Path test-clone) { | |
rm -Force -Recurse test-clone | |
} | |
} | |
function Create-RepositoryWithMultipleBranches | |
{ | |
git init test-repo | |
cd test-repo | |
echo 1 > file | |
git add --all | |
git commit -m 'commit1' | |
git checkout -b branch1 | |
echo 2 > file | |
git commit -am 'commit2' | |
git checkout master | |
git checkout -b branch2 | |
echo 3 > file | |
git commit -am 'commit3' | |
git checkout master | |
cd .. | |
} | |
function Clone-AndCheckoutAllBranches | |
{ | |
git clone test-repo test-clone | |
cd test-clone | |
git checkout branch1 | |
git checkout branch2 | |
git checkout master | |
cd .. | |
} | |
function Remove-RemoteBranches | |
{ | |
cd test-repo | |
git branch -D branch1 | |
git branch -D branch2 | |
cd ..\test-clone | |
echo "Branches before prune" | |
git branch -v --remote | |
git fetch -p | |
echo "Branches after prune" | |
git branch -v --remote | |
cd .. | |
} | |
function Run-Main | |
{ | |
Clean-TestRepos | |
Create-RepositoryWithMultipleBranches | |
Clone-AndCheckoutAllBranches | |
Remove-RemoteBranches | |
cd test-clone | |
} | |
Run-Main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment