Atios Atios - 2 months ago 10
Git Question

Git Branching, what am I doing wrong?

I am just starting with Git Branches, here's what happened:

Step 1: I initialized a Git Repository

(master)
with
git init
.

Step 2: I added and committed the "initial commit".

Step 3: I created a branch and switched to it to start developing on it (I called it
myproject_dev
).

Step 4: I made some changes to the newly created
(myproject_dev)
branch.

Now when I type
git status
in the
(myproject_dev)
branch I see those changes that need to be committed (that's good)!

BUT when I switch to the
(master)
branch and I type
git status
I also see the changes that I made in the
(myproject_dev)
branch, which those changes should only be in the (
myproject_dev)
branch, unless the branches get merged!

What am I missing here?

Answer

You need a step 5 which actually commits those changes to myproject_dev branch, otherwise those changes stay in the working tree when you check out other branches.