0

I had one git branche - BRANCH-1

Following are the steps I followed:

**STEP-1:** git checkout -b BRANCH-2 BRANCH-1 // creates BRANCH-2 from BRANCH-1 and switches to BRANCH-2

I make changes to some files in BRANCH-2 I do not commit

**STEP-2:** git checkout BRANCH-1 // switches to BRANCH-1
M       file.name
Switched to branch 'BRANCH-1'

After STEP-2, git moves to BRANCH-1 , but it also changes the file.name on BRANCH-1.

How do I checkout/switch between BRANCH-1 and BRANCH-2 with keeping their changes only to the respective branches

rumit patel
  • 1,891
  • 5
  • 23
  • 28
  • You should not be even attempting to switch branches if you have uncommitted/unstashed work. I'm surprised you were able to switch from `BRANCH-2` to `BRANCH-1`. Please review a Git tutorial. – Tim Biegeleisen Apr 07 '16 at 06:24
  • commit or stash your changes – pratZ Apr 07 '16 at 06:24
  • You shouldn't afraid to commit changes, even if they are temporary or can break things. You can always correct commits before pushing. – Foolish Apr 07 '16 at 06:25

0 Answers0