11 ms·
Git is, like many professional tools, something you simply got to learn. But like with many professinal tools, you don't need to know everything to get to work
by k__ 10y ago
Git is, like many professional tools, something you simply got to learn.
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:
git init // crate new repo
git status // show which files are changed and which of them are staged
git add -p // add "chunks" of changed files to the stage
git commit -m "<commit_msg>" // commit everything added to the stage with a commit message
git log // show a list of commits
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)
If you want to work with a repo from somewhere else like Github etc., you need a few extra commands:
git clone <repo_url> <target_dir> // clone a remote repository locally
git pull // download and merge new commits in the remote repo that happened since the last clone/pull
git push // uploading your own changes after a commit to the remote repo
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.
- vbtemp 10y ago> Git is, like many professional tools, something you simply got to learn. Nailed it.
- rplst8 10y agoAgreed. I'm seeing terms like "elitist" being thrown around below for "git apologists" when it's simply a matter of learning a tool. Not everyone needs all the power of the git CLI and the complications it brings - but when you do need it, it's there to fix the dumb things we all do sometimes. 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.
- nickpsecurity 10y ago" I'm seeing terms like "elitist" being thrown around below for "git apologists" when it's simply a matter of learning a tool." 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.
- andybak 10y agoNo-one is disputing the power of git. People are merely pointing out that it's textual user interface is clunky and inconsistent. Just because it won the DVCS wars doesn't mean the conversation needs to end and we have to accept this is as good as it gets. It won despite it's CLI not because of it.
- matt4077 10y agoThis is very close to the result of the study that was I believe he reason to write gitless: - 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.
- deleted 10y ago[deleted]
- copperx 10y agoIf both groups get the mental model wrong, how can we ever hope to get it right? read the Git source code?
- globuous 10y agoNo, but there's a book called "Pro Git" by Scott Chacon and Ben Straub that popped up on HN not too long ago. It does explain git on the lower level without going into the git source code. 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.
- matt4077 10y agoI never realized how much of a tool git users were before I knew there are 500 page 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.
- norswap 10y agoI think git's concepts are simple and worth learning (unlike what the gitless people said). That being said, the command line interface is "meh" at best and full of byzantine options.
- yawaramin 10y ago> I think git's concepts are simple and worth learning 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?
- norswap 10y agoFor instance, git has a notion of staging area (the index) where you collect the changes that go into a commit. In gitless, all changes to tracked files are committed. The index goes a long way towards making nice commits that can be understood by other team members, pass tests, etc. Similarly, the stash that allows you to save your uncommitted changes before switching branches is also quite worthwhile.
- yawaramin 10y agoFor all intents and purposes, gitless has an index too. It lets you specify upto hunk-level granularity what you want to include in (and exclude from) each commit.
- skybrian 10y agoI'm quite comfortable with git now but I also remember what a pain it was to learn. This included making mistakes and diving deep into git's internals to recover. The question is whether we should make things easier for new versus experienced developers? 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.
- lbotos 10y agoVersion control is arguably confusing for beginners, but building a shim instead of learning the tool isn't the answer in my head. 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.
- k__ 10y agoIt's like with IDEs. 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.
- ern 10y agoI may have misunderstood you, but you do realize that Mercurial is also a DVCS like git, right?
- 10y ago
- weberc2 10y agoI don't think those commands are remotely sufficient to work with git. You're forgetting about merging, traversing history, branch creation, remotes, grokking the staging area, etc. I'm sure I'm missing a lot as well, because those of us who have worked with git for a long time take these things for granted. And it does frustrate me that it's so complex, because Mercurial shows us it doesn't have to be this way. Unfortunately, Mercurial never took off (presumably because it never had a good GitHub analog).
- StavrosK 10y agoHow are they forgetting merging, remotes, etc? The commands are literally on the front page. The only thing it doesn't have is a staging area, which is a conscious decision that I happen to agree with.
- k__ 10y agoThe commands are enough to get through the first month of using git for your own project. They are certainly not enough to work with Git for your whole career :)
- weberc2 10y agoThe examples I mentioned were taken from notes I made myself when I was learning git (whenever I had an "aha" moment, I would make a note so I wouldn't forget how to work around it later, since I didn't know the git jargon and thus couldn't Google effectively). Maybe my experience is atypical, but at the time I didn't think I was doing anything novel.
- tree_of_item 10y ago> Git is, like many professional tools, something you simply got to learn. 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.
- k__ 10y agoWhy would someone write a tool for 10 commands?!
- tree_of_item 10y agoNo one here did that. What are you talking about?
- chowells 10y ago"Professional" doesn't mean "Poorly designed". It means "designed so that people with lots of domain knowledge and experience with the tool find that it never gets in their way." 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..
- snoman 10y agoThe burden of having to know everything about it, is precisely what gets in your way. Granted, I use an actual tool (sourcetree) that abstracts away the BS that is the git commandline. 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.
- slavik81 10y agoI think this is because the commands are poorly named and badly organised. Professionals will use it frequently enough that they remember everything they need and find it easy from that point forward, but for beginners the unintuitive commands are a double-whammy. It's hard to find the command you want, and the poor naming is a hinderence to building a good mental model of the system.
- pjmlp 10y agoActually I miss using Mercurial and most customers that I work with, refuse to move beyond Subversion into Git. Those that do move, just use Git workflows as if it was Subversion.
- lisper 10y agogit 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.]
- chungy 10y agoThen use `git checkout -f` if it so pleases you. There's more than one way to skin a cat.
- ender7 10y agoTo be honest, this comment is more evidence of a problem than anything else.
- jjoonathan 10y agoBut they don't do "exactly the same thing, with the only difference being..." unless you ignore the index, which is one of the extremely powerful abstractions that sets git apart. Sure, git could expose a simplified lowest-common-denominator interface that plasters over its differences, but the same interface would (and gitless does) plaster over its strengths and encourage people not to learn them. 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.
- strictfp 10y agoThey don't do the same thing implementation wise, but they do the same thing ux wise. This difference causes all discussions like the above: it seems as if some people like ux "plaster", while others like bare-metal tools.
- tadfisher 10y agogit wasn't designed to be used by humans. I can't find the quote, but Torvalds said at one point that intention of Git was to provide a content-addressable graph that more human-friendly tools could build upon for different use cases. 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.
- nickhuh 10y agoI could be wrong, but I think the article that the Torvalds quote came from was purely satirical [1]. If you look at the tags it says it was posted under satire. Got me at first too! [1]: http://typicalprogrammer.com/linus-torvalds-goes-off-on-linux-and-git/ http://typicalprogrammer.com/linus-torvalds-goes-off-on-linu...
- aidenn0 10y agoHere's one quote from Torvalds to that effect: http://www.gelato.unsw.edu.au/archives/git/0504/0873.html http://www.gelato.unsw.edu.au/archives/git/0504/0873.html
- eridius 10y agoGit wasn't originally designed to be used by humans. There was a separate "porcelain" built on top of git, but I no longer remember what it was called. But enough people wanted to just use git proper without the porcelain that the git core commands evolved into a porcelain themselves, and the separate porcelain layer was deprecated.
- bsder 10y ago> Git is, like many professional tools, something you simply got to learn. 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".
- mitchty 10y agoI persist in using git mostly because it doesn't also mean I need to have python installed everywhere. 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.
- bsder 10y ago> I persist in using git mostly because it doesn't also mean I need to have python installed everywhere. 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.
- gjolund 10y agoGit bisect should be on this list.
- foxylad 10y agoYep, that's pretty much my git repertoire! I would add branch and merge to this list - conceptually simple, but they add another dimension to version control.
- fragmede 10y agoExample usage from the article: $ 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/ 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.
- vatotemking 10y agoI just use Git GUI. Click click and I'm done. For more complex tasks I open up Git Bash eg. git merge --no-ff <branch> which is the equivalent of "gl merge" command in gitless
- eriknstr 10y agoAfter having used git for a few years, I identified what commands I use most frequently and have created two-letter aliases for these; 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.
- marcandre 10y agoIt's way superior to use git aliases instead of shell aliases. In this way autocompletion and autocorrection will work.
- eriknstr 10y agoFor the specific aliases I have, the only one that needs an argument is commit and you can't auto-complete a commit message anyway ;) For the aliases that I sometimes specify a file path for, bash is still able to tab-complete that. So for me, shell aliases are actually the best.
- deleted 10y ago[deleted]
- collinmanderson 10y agoMerge Conflicts. 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.
- dahart 10y ago> 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 https://git-scm.com/docs/git-stash
- collinmanderson 10y agoSure, but my guess is it's just as easy to shoot yourself in the foot with rebase -i. Beginners are still going to have a hard time recovering mistakes with rebase -i, even if it's theoretically possible to recover. Plus, now you need to use `git diff origin` rather than `git diff` to see your changes.
- dahart 10y ago> Sure, but my guess is it's just as easy to shoot yourself in the foot with rebase -i. 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=12613062 https://news.ycombinator.com/item?id=12622414 https://news.ycombinator.com/item?id=12622414
- oh_sigh 10y agoThe problem is the world isn't just git. There are thousands of other things to master at any given moment. Putting a veneer over something you aren't interested in mastering and using that seems like a valid strategy.
- chiefalchemist 10y agoTrue. But the argument breaks down (for me) when you consider all the computing power we have, what we're building (i.e., lack of dog fooding), etc. and this must learn tool is the best we got. NO ONE would use Photoshop or Ableton if they're were as messy as Git. Nuff said.