Skip to content

Instantly share code, notes, and snippets.

@tkirill
Created July 3, 2015 13:12
Show Gist options
  • Save tkirill/b266e440f7a09c918246 to your computer and use it in GitHub Desktop.
Save tkirill/b266e440f7a09c918246 to your computer and use it in GitHub Desktop.
Test rig for revert git reset
# for http://stackoverflow.com/questions/31207487/recovering-from-git-reset-hard
function Clean-TestRepos {
if (Test-Path test-repo) {
rm -Force -Recurse test-repo
}
}
function Do-Commit($n) {
echo $n > "file$n.txt"
git add --all
git commit -m "commit$n"
}
function Run-Main {
Clean-TestRepos
git init test-repo
cd test-repo
Do-Commit(1)
Do-Commit(2)
Do-Commit(3)
git branch mybranch
git reset --hard HEAD~2
}
Run-Main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment