简体   繁体   中英

git: change of one branch is showed in another branch

I made some local change of file1.txt in master branch. Then I switch to another branch: "git checkout another_branch", And then I run "git status". It showed "modified: file1.txt" And when I view file1.txt. the file is changed.

Shouldn't change of one branch do not touch another branch?

If you made the change to file1.txt but did not commit the change, it will stay locally even if you switch branches.

If you meant to include the change on your master branch, make sure you commit your change. For example:

$ git add file1.txt
$ git commit -m "Change to file1.txt"
$ git checkout another_branch

If you've committed your changes on the master branch and you've checked out on a new branch from master it will have those changes on your new branch..

Or another possibility you haven't committed your changes on the master branch.. your changes will still show if you checkout on a new branch

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