Reputation: 3221
I am trying to build my local folder as following but could not be done.
master
branchA
branchB
(all 3 branch from same commit)
git checkout branchA -> modify file
git switch branchB -> build/compile branchB
And I build my sources with compiler in branchB.
However, branchA changes are shown. Is this possible to be done in single folder? Or it is only possible if I clone the branches into separate folder?
Upvotes: 0
Views: 74
Reputation: 72755
A modification is not in a branch unless it has been committed.
When you modify a file while branchA
is checked out, it is not part of branchA
(yet). It's just an uncommitted change it the working copy. When you switch to branchB
, the modification is still an uncommitted change in the working copy (although you are on branchB
). If you want branchA
to have this change you've made (and hence be distinct from branchB
), you'll need to add and commit the file which you have modified into branchA
before switching to branchB
.
However, I suspect your workflow has some deeper problems. What exactly do you hope to achieve from switching branches before compiling especially since all the branches are at the same commit anyway?
Upvotes: 3