Sagar
Sagar

Reputation: 1309

Git parent branch is getting changes of child branch

I have a branch called branch1.

I create a child branch by doing

git checkout -b branch2

Then I checkout to branch2 by doing

git checkout branch2

I make some changes on branch2

When I checkout to branch1, I see my code changes I made in branch2.

I don't want parent branch to sync with child branch. I will merge the code changes of child branch into parent branch when I feel that child branch has correct code.

How can I avoid parent branch from getting code changes of child branch ?

Upvotes: 3

Views: 1038

Answers (1)

BigHeadCreations
BigHeadCreations

Reputation: 1703

That is the way git works. Before switching back to branch1, you either have to commit the changes you made in branch2 or stash them for later.

Upvotes: 5

Related Questions