GIT - Changes in a branch gets reflected in another branch

I created a new branch called "feature" and when I make any changes in this new branch called "feature" it also gets reflected in the "master" branch.

How can I fix this issue?

Answers


This is (reasonably common) misunderstanding:

If you switch branches in git, any uncommited changes (changes you made to files in your working directory, and did not commit) will remain untouched. Thus when you switch branches, it looks like these changes are "following you" through the branches.

In reality, the changed files are simply staying put, waiting to be committed (or discarded).

You should normally not work with uncommitted files for a long time in git. Either make a commit (which you can later discard if the changes were only temporary), throw the changes away, or ignore them.


Need Your Help

Fluid boxes of equal height

javascript css twitter-bootstrap twitter-bootstrap-3

I have a problem creating boxes of equal height for bootstrap 3. In the beginning, I had issues with image sizes being different, so I tried hacking it via JS and resizing them on the fly. The prob...

Is there a way to prevent coupling between unit tests and tested classes

java unit-testing mocking tdd

I have been using unit tests for quite a while. And I have a concern.