File changed on one branch changes on both branches

后端 未结 2 1189
广开言路
广开言路 2021-01-15 11:44

I\'m experimenting with Git on my machine. I cloned some repository and added a new branch my_branch.

In this branch, I edited a row in one source file.

2条回答
  •  走了就别回头了
    2021-01-15 12:06

    Answer to 1: Yes. Like @bmargulies said, unless you do something about it, git keeps the change while you switch branches

    Answer to 2: Yes and No. You should add and commit it the changes if you want them on the branch you were working on. If not, the recommended method is to stash the changes, until you come back to the branch you were working on, and then apply or pop the stash.

提交回复
热议问题