Created
June 2, 2021 11:29
-
-
Save Integralist/baa244ccb85f1e67044136f6e2f71001 to your computer and use it in GitHub Desktop.
[git multiple branches] #git
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
# do some work | |
cd ./repo | |
git checkout some_feature | |
# I need to make a hotfix, but I don't want to disturn my messy 'some_feature' branch | |
# I don't want to have to stash things and get things cleaned up | |
# So I create a new 'worktree' | |
git worktree list | |
git worktree add ../hotfix | |
# open new terminal shell | |
# and make changes in my new 'hotfix' branch | |
cd ./hotfix | |
# merge my hotfix stuff back into 'main' | |
git checkout main | |
git merge hotfix | |
# ensure my original 'some_feature' is up-to-date with 'main' | |
cd ../repo | |
git rebase main | |
# clean-up the 'hotfix' working tree (this will delete that directory) | |
git worktree remove hotfix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment