Say you are working on a branch, and you come up with an interesting behavior you want to archive as an experimental branch. What is the cleanest way to do this?
Cleanest way I can think of off the top of my head:
1) Backup your local version to another directory.
2) git checkout, to revert back to your last commit
3) git branch experiment_name, make the new branch
4) git checkout experiment_name, switch to the new branch
5) Copy your backed up version to the working git directory.
6) git commit, commit your new fancy experimental branch
If you don't have a clean index:
git stash
git checkout -b name
git stash pop
... more edits
git commit
If you have a clean index, you can just create a new branch off the current head:
git checkout -b name
... edits
git commit
Or if you have edits that belong to the current branch and you want to work on a new experimental branch for some time and return then:
git stash
git checkout -b name
... edits
git commit
git branch master
git stash pop
... continue work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With