简体   繁体   中英

Git branches is not independent from master

I create a branch from my master. However, when I checkout into the branch and make changes, these changes appear in my master branch when I checkout back to master. Another very weird thing is that git does not force me to commit when I make changes and do checkout. How can I have a branch that is independent from the master?

I have created many branches before, but I have never run into this problem before.

As long as you don't commit the changes, they will come with you to other branches that you checkout (either on the working tree or on index if you have already added something there).

Now, this question, I don't understand what you mean: How can I have a branch that is independent from the master? Just in case, you can have a branch that is completely independent of master by creating an orphan branch .... but I'm not sure that is what you are asking about.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM