Skip to content

Instantly share code, notes, and snippets.

@sdoro
Created December 13, 2015 09:30
Show Gist options
  • Save sdoro/47c84128d057815d0b42 to your computer and use it in GitHub Desktop.
Save sdoro/47c84128d057815d0b42 to your computer and use it in GitHub Desktop.
Move your latest commits to a separate branch as in https://ariejan.net/2012/08/14/move-your-latest-commits-to-a-separate-branch/
git init
echo "# aaa" > README.md
git add README.md
git commit -m "A" README.md
echo "# bbb" >> README.md
git commit -m "B" README.md
echo "# ccc" >> README.md
git commit -m "C" README.md
git remote add origin [email protected]:sdoro/aaa.git
git tag push-01
git push -u origin master
echo "# ddd" >> README.md
git commit -m "D" README.md
echo "# eee" >> README.md
git commit -m "E" README.md
echo "# fff" >> README.md
git commit -m "F" README.md
# screenshot-01
git branch my_feature_branch
git reset --hard HEAD~3
echo "# ggg" >> README.md
git commit -m "G" README.md
git tag push-02
git push
# screenshot-02
git checkout my_feature_branch
echo "# hhh" >> README.md
git commit -m "H" README.md
git tag push-03
git push --set-upstream origin my_feature_branch
# screenshot-03
git checkout master
echo "# iii" >> README.md
git commit -m "I" README.md
git tag push-04
git push
# screenshot-04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment