Reputation: 2060
I have a master
branch:
Then I make employee
branch from the master
and change it a bit:
And when I swipe between branches, the master
branch also had been changed:
I have no clue why it happens.
Any suggestions how to return it back to norm?
Upvotes: 5
Views: 2377
Reputation: 1444
Make sure you commit to the "X" branch. After you commit to the "X" branch, no change will take place in the main/master branch. But if you switch the master branch without committing to the "X" branch, changes will also be seen in the master branch.
Upvotes: 1
Reputation: 2992
When you make a change in your editor, you only modify the code in your "working directory". When you switch branches, those changes in your "dirty" directory come along for the ride.
Once you commit your changes on a given branch, switching branches will no longer bring those changes over.
(Answer By @Joseph Silber)
Before your case you have three options to make:
A) Maintain changes in the master branch
# Agree
git add file/path/archive
# Perfom a commit
git commit -m "Message"
B) Return branch employee and add changes in this branch
# Since the terminal gitbash or the manually form
git checkout employee
# Agree
git add file/path/archive
# Perfom a commit
git commit -m "Message"
C) Discard all change
This step will undo all changes that have not been previously added to a commit. Caution!!.
git checkout file/path/archive
Upvotes: 1
Reputation: 220146
When you make a change in your editor, you only modify the code in your "working directory". When you switch branches, those changes in your "dirty" directory come along for the ride.
Once you commit your changes on a given branch, switching branches will no longer bring those changes over.
Upvotes: 8