Created
July 3, 2015 13:12
-
-
Save tkirill/b266e440f7a09c918246 to your computer and use it in GitHub Desktop.
Test rig for revert git reset
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/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