4 ms·
They're still right where they were before you switched branches unless you've committed them before you switched branches, of course!
by knicholes 12y ago
They're still right where they were before you switched branches unless you've committed them before you switched branches, of course!
- throwawayaway 12y agomkdir commadir cd commadir git init echo "dog" >> dog.txt git add . git commit -m one echo "dog" >> dog.txt git add . git commit -m two echo "dog" >> dog.txt git log git checkout dog.txt cat dog.txt how many dogs in dog.txt?
- bryondowd 12y agoThat isn't "git checkout <branch>", it is "git checkout <file>" If you try checking out another branch while you have uncommitted changes, git will tell you to commit or stash your changes before changing branch. I can certainly understand the danger/confusion there, though. Using checkout on a file reverts the file to a committed state. But the grandparent was referring to checking out a branch, not a file, which is safe.
- throwawayaway 12y agogit checkout <branch> * has the same behaviour. does it not? I left out the asterisk as I was working from memory.