git checkout <file> // throw away all changes since the last commit (one file)
git reset --hard // throw away all changes since the last commit (all files)
This is a perfect illustration of why git needs a better UI. Two different commands to do exactly the same thing, with the only difference being that one is for one file and the other is for many files? If you tried to design a hard-to-use UI you could hardly do better than that.[NOTE: these two commands actually don't do quite the same thing, which is part of the problem.]
`git reset --hard` discards the index _and_ any unindexed changes. You can think of it as essentially `git reset` (which discards the index) followed by a `git checkout .`
I think a lot of the murkiness of git's usability comes from the fact that many commands have collected convenience flags that replicate the behavior of other commands. The rest comes from the fact that `git checkout` and `git reset` can affect any or all of 1) the contents of the working directory 2) the contents of the index 3) the contents of repository metadata like branch tips and HEAD, and you pretty much just have to learn what does what.
I agree with TFA: this isn't a UI issue, it's an abstraction issue. Several of git's abstractions only make cost/benefit sense in a distributed environment. Unbundling the cost of learning dVCS abstractions would make git a better fit for the Cathedral and a worse fit for the Bazaar. This might be what you want, but you should at least be able to understand why other people do not want it.
> git checkout [--detach|-b] <commit-ish>
Set HEAD to a new place and sync the working-directory/index to it.
> git checkout <paths>
Copy paths from the index to the working directory.
> git checkout <tree-ish> <paths>
Copy paths from a given commit to the working directory.
This means that "git checkout HEAD file" is different from "git checkout file".
Similarly, `git reset` has 2 modes:
> git reset <tree-ish> <paths>
Copy paths from a given commits to the index, leaving the cwd unchanged.
> git reset [--soft | --mixed | --hard] <commit>
Set *HEAD to a new place, and optionally sync the working directory/index to it.
This is obviously terrible, but changing the names now might be worse.
I share your concerns for consistent tooling, but the idea of becoming proficient in something without putting in the effort is not reality.
Because he's the one who said that they do the same thing.
- Most people use git by learning a set of a few commands
- A minority actually understands git on a deeper level
But both groups form a mental model of how git works, and that model is apparently usually wrong, which results in those cases were you get stuck and just start with a fresh checkout and manually reapplying the changes you wanted to commit.
This book is over 500 pages, but chapters 1 to 3 will get you up and efficient within 2 hours. Especially chapter 3 (I skipped to it, I kinda knew the basic git commands from "experience"), which goes over branching and how it works. It explains how snapshots are handled and what points to what, which make working with multiple branches locally and remotely a pleasure actually.
It's honestly not to hard to get decent at git. Although I never realized how much of a tool git was until I heard about people writing 500 page long books about it.
This whole thread is evidence of two opposing viewpoints: "git is too hard" and "git is powerful, professional tool and that requires some effort".
I believe those making the latter point misunderstand the first group (to which I belong): I'm not opposed to putting in some time to learn a tool that's central to my craft.
But git seems to often be complicated not because of the complexity of the underlying problems, but because of choices made in its implementation.
Consider: If you have a decent understand of information theory, you'll be able to use any database system within a short time, even if you never had heard of SQL before. Indeed, with a few years of SQL, you'll quickly understand NoSQL systems as well – coming from Postgres, I was productive in Redis within half an hour.
But no amount of experience with VCSs will allow you dive into git without hitting a brick wall.
Most people use it like a svn with better branching and merging.
I think a lot of tutorials spend a lot of time teaching you the index/staging (a non-trivial concept that beginners don't need) but don't teach you how to survive merge conflicts and other common tricky situations which beginners are likely to run into if they're collaborating.
Your list is all you need...until you try to `git pull` and it says
> Cannot pull with rebase: You have unstaged changes.
You're only option with your list is commit your changes, but I think it's better to `git stash` then `git pull` then `git stash pop`
Though when you `git pull` you can get a merge conflict and there's two different ways to resolve it depending on if you used the `--rebase` flag or not.
Once you're done resolving those conflicts, you run `git stash pop` and could possibly get yet-another merge conflict that needs to get resolved.
Basically, I'd add `git stash` to your collaborative list. You can't `git pull` without it.
Of course you can! Git stash is not necessary for any workflow, it's pure convenience.
Best practice is not to pull with unstaged changes. If you want to, then:
$ git commit -am "WIP"
$ git pull --rebase
Easier than stashing! But this does mean you're going to need to rebase -i later before you push.Stash is dangerous for beginners, I don't recommend learning it first. From the stash man page:
"If you mistakenly drop or clear stashes, they cannot be recovered through the normal safety mechanisms." https://git-scm.com/docs/git-stash
Plus, now you need to use `git diff origin` rather than `git diff` to see your changes.
No. rebase -i goes in the reflog. stashes don't. The rebase man page does not have the same safety warning that the stash man page does. I have personally witnessed a lot of stash accidents, and not many rebase accidents.
With a rebase, if you have a bad merge conflict, you can abort. With a stash you can't. If you've committed your changes and have problems either forgetting what you're doing, or with merge conflicts, or with being in the wrong branch. All of these cases have more undo options with commits. In the worst case, you still have the safety net of the reflog with commit. With stashes, your only safety net is hunting for dangling blobs using fsck.
Previous threads: https://news.ycombinator.com/item?id=12613062 https://news.ycombinator.com/item?id=12622414
They are certainly not enough to work with Git for your whole career :)
If switching to gitless became a thing I'd have to learn something new, but if it made things significantly easier for beginners, maybe my personal inconvenience isn't that important.
I always struggle with "lowering the barrier of entry" and it's not a "I did it they need too do it" it's more of a "Usually high barriers mean it's complex, and learning how to understand complex things is important."
If this was some new novel way to version that wasn't just pretty git, I'd be a lil more excited.
Now the guy was pretty technical (part of his job was AS development), but he was not a developer.
Darcs's and Git's fundamentals are not that different[0], but Darcs's CLI actually makes sense in and of itself independent from the implementation details, and when it diverges from the older standard (e.g. SVN) it's so that commands make more sense, not less. Meanwhile Git has taken pretty much the opposite tack.
Git's porcelain is a giant steaming roasted turd sandwich, no other DVCS has such a complex, hostile and nonsensical CLI that people tell you you're supposed to learn it from the storage model up and then it'll make sense.
Don't try to shift the buck to VCS/DVCS concepts, while they are complex Git's CLI goes a great way towards making them nonsensical to beginners and non-beginners alike. I routinely used three different DVCS before I had to take the plunge into Git, and it was still a fucking pain in the ass. And that's a problem at every level of resolutions, just compare the hot mess that is gitrevisions(7) to mercurial's (more powerful, more flexible, more readable and more regular) revsets. It's not like revsets are a genius's flash of inspiration either, "hey I'm trying to manipulate sets of revisions, how about I manipulate them as sets?" We're not talking turing award worthy discovery here.
[0] well they kinda are, but by and large the fundamental differences are irrelevant to basic day-to-day use.
NO IT IS NOT. <smack to back of head> That kind of thinking is broken.
Most people who have been around computers on Windows long enough eventually adopt it. They start creating zip files of directories and they put date codes on them. You laugh, but it works.
As such, it's really easy for me to explain Mercurial to them. I simply explain it that Mercurial holds those zip files with some extra information and a pretty GUI. It takes me 30 minutes, max, and they get it.
They have one branch. They occasionally share things with other people. And, very occasionally, they have to merge something--which generally gets resolved by taking this file or that file--but rarely actually merging content.
Things only start to go bad when you start adding concepts that require the user to keep state of the repository in their head. If the end user has to think about the DAG, yeah, THAT'S complicated. And that's broken.
I've now been using git and hg for so long that I know both. I now know enough about git that I have been able to unwedge my teams without just copying the repo (cue xkcd link: https://xkcd.com/1597/). I don't need to spend hours of Googling anymore, I just need quick reminders of "Oh, yeah, that stupid flag."
And, you know what, I have never, ever been in a situation where I thought "Gee, I really wish I was in git rather than Mercurial." The converse, however, happens at least once a week.
Perhaps one day my teams or my repos will be complicated enough that the light dawns. The fact that the *BSD guys still operate using CVS and Subversion makes me skeptical.
We should be celebrating better UIs over important tools, not saying "I made great effort to learn it, therefore learning it with less effort is inferior". No. If it does everything Git does, but more easily, it is strictly superior.
Meanwhile, unlike Git, I understood most of Gitless's commands before the tutorial started explaining them. Opposite experience I got with Git tutorials where I kept questioning why it would be done a certain, unintuitive way. This is definitely an improvement.
I don't think git's command line needs to be changed, though.
>If it does everything Git does, but more easily, it is strictly superior.
In the abstract I agree, but if an junior dev goes "oh, I just use gitless because it's easier" and DOESN'T understand git, it's a problem. That's my point.
I'm always suspicious of arguments like this, because they have a Luddite quality to them. Isn't sending email versus handwritten postal mail "cheating the effort" of communication?
git is a lot of effort to learn because its command line is inconsistent and it is frequently unclear what it has done, why and how to recover from it. It is worth asking if this is really necessary.
If a system has a high percentage of beginners pressing the wrong button and losing time and effort as a result, maybe someone should move the buttons?
Eclipse has stuff like workspaces with multiple projects and others have simply projects. What to do with these workspaces?
Same goes with Git. Simple VCS have central repositories and a working copy. Git has multiple repositories and every one of them can have a working copy. Other VCS don't have a stage, you simply commit your changes directly into your repository.
It's not only that these tools have different commands and stuff like Mercurial or Subversion has easier commands etc. but they really have different concepts that need to be considered while working with these tools on a daily basis.
But you don't have to internalize them on your first week or month working with them. When you got your project in the System it's mostly save and if you don't have complex workflows you can still reap the benefits of VCS with Git without knowing everything.
Or, you can use a tool that is built for purpose aka doesn't suck). I don't use a Stanley #55 Plane to trim an edge even though it can.
Mercurial, the author notes, doesn't have most of the pitfalls. Yes, everybody persists in using git because "Linus used it".
I recognize this may be a minority reason, but that is a significant one. The rest amount to being able to rebase/reorder my commits.
At no point does "linus used it" factor in. What genuine technical points about git besides "doesn't suck" are you espousing as reasons I should switch?
Note, my workplace:
a: uses git
b: is about as likely to switch to hg as a pig would be to fly
c: follows linux upstream closely (we do kernel stuff)
I know of the following things that would be reasons to move to hg, however they're more in the "nice to have" rather than "need" category.
a: evolve extension
b: more consistent ui
If I were to list out all the cons for hg from my current perspective, here would be my top 5:
a: have to unlearn fetch/pull as they are not the same between tools, which is right is academic at this point
b: have to unlearn a lot of git use over the past 8 years, not against it but I need a good carrot to bother
c: now I have to install python on some low power systems, honestly this is dumb needing to install a scripting language just to use a VCS, and I use python daily, but its extra bloat that really shouldn't be needed.
d: last I looked (~6 months ago), i'd need to install extensions to recreate most of my workflow, again, this boils down to more effort than sticking with the status quo which by and large works out of the box.
e: would be nice if hg proponents would stop with the "git users are brain damaged by bad ui" posts, it honestly just makes me roll my eyes and move on, not rethink my position, SHOW ME WHY IT IS BETTER, stop berating as that isn't helping and at best is making me think people are treating VCS choice as a religion or political affiliation, which is easily dismissed and not at all worth my time to reply.
That is a perfectly valid objective reason. It surprises me, given that I do embedded development and have yet to be in a position where Python in my toolchain is an issue, but I'm happy to concede it.
> c: follows linux upstream closely (we do kernel stuff)
Then git is your horse, full stop. Even as a Mercurial person, if I was following kernel stuff I'd use git, that's just common sense.
> e: would be nice if hg proponents would stop with the "git users are brain damaged by bad ui" posts, it honestly just makes me roll my eyes and move on, not rethink my position, SHOW ME WHY IT IS BETTER
You do realize that the UI is more than the majority of the tool, right?
People have done what you ask for. Repeatedly. Including the parent post. Git power users have written extensively of the various UI brain damage and the problems it causes for non-power users.
Git people concede the UI sucks and still persist in starting new projects with git. How should that be classified?
> If I were to list out all the cons
Do be cognizant that with the exception of objecting to python, most of your list of cons is: "I've used git and optimized for it so changing is difficult". If Microsoft/Oracle were attempting via network effects to foist such a broken tool on the open source community instead of Linus/github, people would be screaming.
Personally, I can use either now. Also, personally, I now consider Mercurial to be a not-so-secret productivity advantage (well integrated with Windows, no wedged repositories, no wasted time recovering, can explain how to use it to neophytes so executive level people and non-programmers can use it, etc.). I know that my Mercurial teams won't waste 5% of their time fighting their source code system every single week--they won't even think about their source code system.
My beef is that beginners think "Oh, everybody uses git so git is fine so let's use git". And then, once they've made that mistake, now they feel they have to defend it. And that's not cool.
Admittedly its weak but I've used it to run things like git on some really small systems. I'd rather not have to try to get python running on something like an AVR. But to each their own. Not sure what embedded development is meaning here exactly but no matter.
> You do realize that the UI is more than the majority of the tool, right? > People have done what you ask for. Repeatedly. Including the parent post. Git power users have written extensively of the various UI brain damage and the problems it causes for non-power users.
I'm looking more for what advantage hg itself gives me, less about how much git sucks which is at this point beating a dead horse.
> Do be cognizant that with the exception of objecting to python, most of your list of cons is: "I've used git and optimized for it so changing is difficult". If Microsoft/Oracle were attempting via network effects to foist such a broken tool on the open source community instead of Linus/github, people would be screaming.
Indeed, but that just points to after 8-9 years of using git, minor gains in using hg just don't seem as warranted. To date most of what I have seen with hg hasn't shown me what I will gain from switching will be greater than moving. Perhaps thats due to not having to use hg constantly but with things like magit I really don't notice the git ui a lot unless I choose to drop into the command line.
> Also, personally, I now consider Mercurial to be a not-so-secret productivity advantage (well integrated with Windows, no wedged repositories, no wasted time recovering, can explain how to use it to neophytes so executive level people and non-programmers can use it, etc.). I know that my Mercurial teams won't waste 5% of their time fighting their source code system every single week--they won't even think about their source code system.
For my work I've no real need to integrate with windows, not sure what wedged repositories is referring to. Recovering is vague but as a worst case the reflog has always been an emergency fixer. I've not really experienced this to be honest and I'm basically the go to guy for git with my team.
> My beef is that beginners think "Oh, everybody uses git so git is fine so let's use git". And then, once they've made that mistake, now they feel they have to defend it. And that's not cool.
Thats fine, but a bit different than the original statement of Linus uses it therefore we must. It is more git is widely used, ignoring it or not knowing how to at least basically use it isn't a tenable position imo. But to each their own.
Those 10 commands are the beginning of the iceberg when you actually start using git with teams. Where are `rebase`, `merge`, `branch`, etc? These are all commands I use daily, they are complicated, and it's trivial to shoot yourself in the foot.
The problem is that you can learn those 10 commands and things will work, until they don't, and you as a beginner are now spending hours trawling StackOverflow to figure out how to, say, pull a commit from one branch to another (you might not know that such a process is called "cherry-picking").
It's telling that Torvalds said this more recently about git:
> The first Git For Dummies and Git Visual Quickstart books are going to be out in a couple of months, and that is the beginning of the end as far as I’m concerned. Those books mean the end of git expertise and github reputation as reliable indicators of geek status. Once a technology is adopted by the masses the extreme geeks find something more esoteric. Look at what happened to Ruby on Rails. The people stumbling their way through Rails to-do list tutorials have never even heard of DHH.
[1]: http://typicalprogrammer.com/linus-torvalds-goes-off-on-linu...
alias st='git status' # STatus
alias dp='git diff' # Diff Pending
alias aa='git add .' # Add All
alias di='git diff --cached' # DIff
alias cm='git commit -m' # CoMmit
alias pu='git push' # PUsh
I've added comments above to show you what I think in my head when I type the two-letter alias in question.I have a few other two-letter aliases for git as well but the ones above cover about 80% of my use I think.
For the remaining 20% I usually type the command out fully even if I have an alias for it, because those less-frequently used commands are harder to remember the aliases for, whereas the aliases that cover the 80%, I have those in my fingers now without having to think about it.
That being said, the command line interface is "meh" at best and full of byzantine options.
For what purpose? The reason for using a VCS is to get your job done. If gitless does that, why should I need to learn the concepts of a content-addressable graph storage and traversal format?
Similarly, the stash that allows you to save your uncommitted changes before switching branches is also quite worthwhile.
Those that do move, just use Git workflows as if it was Subversion.
$ gl checkout foo.py
You have uncommitted changes in foo.py that would be
overwritten by checkout. Do you wish to continue? (y/N)
> y
A cheat sheet with those 10 commands are enough to get started, but Git takes a bit to grok properly ( https://xkcd.com/1597/ ). More importantly, it doesn't have to be user hostile. Professional tools in manufacturing are very expensive and last decades. Software lifecycles are shorter and easier and far cheaper to replace.NO ONE would use Photoshop or Ableton if they're were as messy as Git. Nuff said.
Nailed it.
I think if you look deep in the guts of Clearcase for example you will see nastiness that makes git look like the ls command.
Some tools people encounter seem unintuitive and have a steep learning curve. Others that do the same thing are super easy to understand and learn. Git vs Gitless is a good example where Gitless instantly clicked with hardly a thought. That means it was a superior interface. That also means anyone telling people they need to suck it up and just accept bad interfaces that smart people were able to learn with enough wasted energy is a bad idea.
Reminds me of those guys when I first started dealing with Linux who told me I was just being slow or lazy for expecting an installer that just required a little bit of input like I had with Windows. Anyone should know everything about handling partitions, configuration of low-level graphics, init systems, whatever. These days, the installers are point-and-click for average case while including options for others. So, why did the Linux people tell me that early on? They were elitist snobs peddling bad UI's and seeing no value in good ones. That simple.
No. Why do people think "professional" has to mean "poorly designed"?
But then, the rest of your post seems to miss the point of this thing entirely. You go on to say that you basically only need 10 commands...which is pretty much the insight that lead to Gitless in the first place.
In that sense, git is a professional tool. If you know everything about it, it doesn't get in your way. The problem is when you don't know everything about it..
The problem with git is the lack of coherence in its default UI. Multiple ways to accomplish the same task, git commands which perform incredibly different functions depending on (invisible) context, inability to decide whether commands or flags should act as the highest-level switches...
It is simply the case that, no matter how beautifully and cleanly designed git's internals might be, the interface it presents to them has zero conceptual integrity.
Visual SourceSafe springs to mind here...
Git, by comparison, is very flexible and allows you to do an awful lot, when you've learned it. You can learn SourceSafe inside out and still have it be a total pain in the arse.
Nothing in that interface is designed to aid in learning. Nothing in it is designed so that mastering one task provides discoverability or intuitability of how to perform another task. It is a complex mess of inconsistencies, discontinuities and obscurities which point more to a lack of design or even of someone with authority to perform design than to anything else. It can only be "mastered" through rote memorization, and bears no necessary or useful relationship to the underlying data models and structures whatsoever.
I have no particular view on how good or bad git's command line is - I have greatly enjoyed using SourceTree though, and the underlying DVCS seemed not to get in the way.
This idea that 'if you don't like the tool, it's because you're not good enough to use it, because you don't know everything about it' is elitist hokum.
many NTSB studies show that even master pilots with thousands of hours of training and flight time make (often fatal) mistakes due to confusion in understanding the cockpit readings
For example, the Army found that using glass cockpits doubled or quadrupled the accident rates in UH-60 and OH-58 aircraft respectively, increased it by ~30% in the AH-64, and reduced it by ~40% in the CH-47.
http://oai.dtic.mil/oai/oai?verb=getRecord&metadataPrefix=ht...
http://www.usaarl.army.mil/TechReports/2001-12.PDF
A five-year NTSB study found that although glass cockpits had twice the incidence rate of fatal accidents. The study concluded that glass cockpits do not show a safety benefit. This remains the position of the NTSB.
http://www.ntsb.gov/safety/safety-studies/Documents/SS1001.p...
http://www.ntsb.gov/news/events/Documents/2010_Glass_Cockpit...
http://www.ntsb.gov/safety/safety-recs/recletters/A-10-036-0...
The reality is that simpler is sometimes better. Mechanical instruments each do one thing and they do it well. Vacuum-driven systems are simple and extremely reliable. You cannot fly a 100% glass cockpit, period.
What glass cockpits really do well is information integration. That makes it easier to surface relevant information for the pilot but it also means that pilots have to handle more complex systems that are throwing more information at them, and yet also may not be throwing the right information at them.
This is an inherently one-way street, the reason we have the instruments we do is because they're relevant, you can't go hiding relevant information from the pilot. As such, NASA recgonizes that glass cockpits and cockpit automation impose a higher cognitive load on pilots. It's very simple and straightforward to interact with a traditional cockpit, but with a more advanced cockpit you also need to have a correct mental model of what's happening in the background, otherwise "cognitive mismatch" will result.
Just like any other abstraction - it's nice when they work but all abstractions are "leaky" to some degree or other and you need to know how it works and be able to route around the problem to fix the cases where it fails.
The long and short here is that experience and frequent training are the key factors in aviation safety and glass cockpits actually increase the requirements in this area. They're nice when they work but they certainly are no panacea.
http://human-factors.arc.nasa.gov/flightcognition/research/s...
https://www.thinkmind.org/download.php?articleid=achi_2012_1...
GUIs and "UX" are generally antithetical to making a computer do what it does best (automate things instead of creating more busywork).
I agree with you, but although CLIs are explicitly automatable, they are almost never are because most operations are one time deals. If you have evet set up a Linux server I think you'll understand what I mean. The CLI is also a usability nightmare with no discoverability.
Except for helping the 6 or so billion people in their daily lives, but hey, the iPhone would be 'better' if it just had 'bash'?
Read your email lately from bash?
Didn't think so!
Now, I use pythonista as a python-shell. Being able to chain a couple of commands and fix a good-enough solution saves a lot of time in many cases such as web scraping on-the-go.
I know this may be an extreme use case, but if iPad is going to be a laptop replacement we need to be able to get a way to speak with it without immidiate access to a laptop.
It's not a false equivalence at all.
The necessity of lower-level technology in the creation of higher-level technology does not imply that the lower-level technology is somehow 'better' or 'superior'.
You are using a UX right now to read and respond to this.
It's crazy to posit that 'UXs are inferior'. Positively wrong.
In the vast majority of cases, UX's are superior to shells. Maps, news, social media, browsing/buying things, listening to music, making music, photo editing - there are actually very few use-cases wherein the shell is advantageous. Even emacs is a UX of sorts.
GUI:s are superior for the specific (limited) use cases they are designed for, inherently since they were designed to excel at those use cases. They are however less optimal when you want to diverge from those use cases and create something new. This is where malleability/modability comes in, and where CLI:s, bash, scripting, programming comes in, and you can't use limited-scope apps for that.
All tools are best at what they were designed for, I agree with you there. I'm however not sure how I in your mind was wrong before. The two are intrinsically bound, but it's undeniable that apps can't exist without tools, but tools sure can exist without apps.
With all the security concerns and regulation regarding flight, it's easy to imagine how hard it is to move forward and innovate in usability.
I'm not saying upending git for something better would be trivial, but I don't want to constrain my imagination by thinking it's not possible.
If you can coherently explain what you need [git replacement] to do, and explain it simpler than you would explain git itself, then you have an outline of a superior tool.
But like with many professinal tools, you don't need to know everything to get to work.
I don't know all Photoshop or Ableton Live features, but I can improve my photos or create songs non the less.
With these commands you can already start your own repo and work on it locally:
If you want to work with a repo from somewhere else like Github etc., you need a few extra commands: I think these 10 commands are all that is needed to get your own project into Git.Yes, the more people are working on a project, the more commands you need, like creating a new branch and getting commits from one branch to another, or amending commits because you forgot something etc.
For a professional tool this isn't too much, I think. The 10 commands I mentioned will be remembered in less than a week. Most of the rest isn't needed often (maybe merge/rebase and branch depending on how you intend to use Git), but they shouldn't take too long either.