Reputation: 21
Suppose I wish to work on two features A and B. I created two corresponding branches feature-A and feature-B (in addition to the master development branch). Whenever I make changes in a branch, do I need to commit my changes before checking out to another? If so, is there any workaround for this?
Upvotes: 0
Views: 990
Reputation: 311635
You could look into git worktrees. This lets you check out multiple branches at the same time in different directories. Let's say you start with two different branches:
git branch featureA
git branch featureB
You can check these out in their own directories like this:
git worktree add work-on-featureA featureA
git worktree add work-on-featureB featureB
Now you can simply move between the two feature branches by changing directories. Once you no longer need the worktree, remove it with git worktree remove
:
git worktree remove work-on-featureA
git worktree remove work-on-featureB
Upvotes: 1