user2644113
user2644113

Reputation: 1151

(Mis)understanding Git branches and checkout

I have a branch, v5, and I create a new branch, v6, to test a new feature. I make some changes to a few files and add some files before committing changes into the branch.
When I checkout the v5 branch, the changes to the common files were 'rolled back' to v5 as I expected, but the new files that I thought were specific to v6 are now part of v5. Why?

Upvotes: 0

Views: 82

Answers (2)

Edward Falk
Edward Falk

Reputation: 10113

Sounds like you didn't do "git add" to the new files before you did your commit on branch v6. They're still untracked, and git will just leave them lying around as you switch branches.

Upvotes: 5

forvaidya
forvaidya

Reputation: 3315

Assuming you have done "git add" and "git commit" on branch v6, on checkout of branch v5, add files will disappear.

In case of windows open files doesn't get removed. They will remain as new files.

Files will get removed from index but will remain in working directory. If you want remove them from work tree try "git clean -xfd" and that time no file should be open.

Upvotes: 0

Related Questions