3 ms·
that can happen, but it can also serve as an excuse. in git, for example, why can’t i switch branches with uncommitted changes? it makes no sense why i can’t d
by nikofeyn 9y ago
that can happen, but it can also serve as an excuse.
in git, for example, why can’t i switch branches with uncommitted changes? it makes no sense why i can’t do that, but yet, there it is.
> there’s a reason why more complicated tools like git have taken over from less-capable tools like Subversion and CVS.
i don’t think the reasons have much to do with usability or even capability. i came to git from perforce, where the latter was much easier to use, reason about, fix issues, and has much better tooling, in particular visual tools. it’s also amazing how slow git is.
- stouset 9y ago> in git, for example, why can’t i switch branches with uncommitted changes? it makes no sense why i can’t do that, but yet, there it is. Except you can? [stouset:~/Development/some-project] some-branch(+8/-4)+ $ git status On branch some-branch Your branch is up to date with 'origin/some-branch'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: path/to/file1 modified: path/to/file2 no changes added to commit (use "git add" and/or "git commit -a") [stouset:~/Development/some-project] some-branch(+8/-4)+ $ git checkout master M path/to/file1 M path/to/file2 Switched to branch 'master' Your branch is up to date with 'origin/master'. > i don’t think the reasons have much to do with usability or even capability. i came to git from perforce, where the latter was much easier to use, reason about, fix issues, and has much better tooling, in particular visual tools. it’s also amazing how slow git is. Perforce isn't free. git's popular predecessors were. That said, I've found in my experience that way more people seem to hate Perforce than seem to hate git.
- seanmcdirmid 9y agoGit’s direct predecessor, bitkeeper, wasn’t free.
- three14 9y agoYou only can switch like that sometimes, and it would have been more intuitive if there was an implicit per-branch stash and stash pop when switching branches, which would always let you switch. See https://stackoverflow.com/questions/22053757/checkout-another-branch-when-there-are-uncommitted-changes-on-the-current-branch https://stackoverflow.com/questions/22053757/checkout-anothe...
- defen 9y ago> in git, for example, why can’t i switch branches with uncommitted changes? it makes no sense why i can’t do that, but yet, there it is. You can, if the changes don't conflict with the branch you're changing to.
- merlincorey 9y ago> in git, for example, why can’t i switch branches with uncommitted changes? it makes no sense why i can’t do that, but yet, there it is. Because the working tree having uncommitted changes being blown away would be terrible data loss or a conflicting merge, so when that could happen, git prevents it. Use `git stash` to stash your uncommitted changes before switching branches and you'll no longer have data loss. If you want to apply those changes again use `git stash pop`. If you don't want those changes use `git stash drop`. Why isn't there a commandline option to checkout a branch and do a stash operation at the same time? Because no one has needed it enough to add it.
- coldacid 9y ago>Because no one has needed it enough to add it. Or because those that did need it whipped up a quick and dirty alias to cover that use case.
- chopin 9y agoI wouldn't want this. This would only be useful if the stash is automatically popped when switching back.
- chrismcb 9y agoI think the implication is that switching branches shouldn't blow away your uncommitted changes. And one shouldn't have to stash their changes to switch branches.