Skip to content

Instantly share code, notes, and snippets.

@Integralist
Created June 2, 2021 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Integralist/baa244ccb85f1e67044136f6e2f71001 to your computer and use it in GitHub Desktop.
Save Integralist/baa244ccb85f1e67044136f6e2f71001 to your computer and use it in GitHub Desktop.
[git multiple branches] #git
# 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