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.
Your change is on no branches. If you edit a file, and don't do 'git add', let alone 'git commit', your change will just sit there unless you do something to get rid of it, like git reset --hard HEAD
or git checkout PATH
. If you went and made a clone of your repo you'd see that your change was not in it. If you used git log
you'd see no sign of it.
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.