News for hackers. Stuff that matters.
Re:Key Git Concepts Explained the Hard Way by stouset on Wednesday March 14, 2018 @05:02PM (#16588266)
> A lot of people simply don't understand why source control isn't a problem solved 100% by tooling in a way that requires little to no interaction at all.

This is true of basically all problem domains: "Why isn't X easy? Can't you just do Y?" And it usually just indicates that the person asking the question doesn't appreciate how difficult and nuanced a real solution to X is.

Real-world problems are often difficult and have non-obvious, sometimes-intractable challenges. "Easy" solutions often cause more problems than they solve — there's a reason why more complicated tools like git have taken over from less-capable tools like Subversion and CVS.

Re:Key Git Concepts Explained the Hard Way by nikofeyn on Wednesday March 14, 2018 @06:25PM (#16588880)
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.

Re:Key Git Concepts Explained the Hard Way by stouset on Wednesday March 14, 2018 @07:30PM (#16589308)
> 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.

Re:Key Git Concepts Explained the Hard Way by three14 on Thursday March 15, 2018 @12:21PM (#16594180)
You 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-anothe...

Re:Key Git Concepts Explained the Hard Way by seanmcdirmid on Thursday March 15, 2018 @07:15AM (#16591800)
Git’s direct predecessor, bitkeeper, wasn’t free.
Re:Key Git Concepts Explained the Hard Way by merlincorey on Wednesday March 14, 2018 @08:07PM (#16589484)
> 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.

Re:Key Git Concepts Explained the Hard Way by coldacid on Wednesday March 14, 2018 @08:16PM (#16589533)
>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.

Re:Key Git Concepts Explained the Hard Way by chopin on Thursday March 15, 2018 @03:21AM (#16590983)
I wouldn't want this. This would only be useful if the stash is automatically popped when switching back.
Re:Key Git Concepts Explained the Hard Way by chrismcb on Thursday March 15, 2018 @10:32AM (#16593145)
I 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.
Re:Key Git Concepts Explained the Hard Way by defen on Wednesday March 14, 2018 @07:34PM (#16589337)
> 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.

Re:Key Git Concepts Explained the Hard Way by jonahx on Wednesday March 14, 2018 @10:42PM (#16590100)
> This is true of basically all problem domains: "Why isn't X easy? Can't you just do Y?" And it usually just indicates that the person asking the question doesn't appreciate how difficult and nuanced a real solution to X is.

Upvoted because this is so true, yet it is also only half the story -- let's call it the ignorant or lazy users half. The other half is the ignorant or lazy developer side: that is, developers who don't properly prioritize the 90% use case, and who don't appreciate or understand the natural mental models they should be accommodating and treating as problem constraints.