1 | initial version |
Git allows you to switch branches without stashing local modifications by committing the changes to the current branch, checking out the new branch, and then cherry-picking the commit that contains the changes.
git add .
git commit -m "commit message"
git checkout new_branch
git cherry-pick commit_ID
If there are merge conflicts, resolve them and commit the changes. Otherwise, continue working on the new branch with the changes intact:
git add .
git commit -m "merged changes from previous branch"