9 ms·
> stash some of my changes, switch branch, cherry pick a commit, switch branch, do an interactive rebase reordering commits and dropping one, pop one of my stas
by matheusmoreira 5y ago
> stash some of my changes, switch branch, cherry pick a commit, switch branch, do an interactive rebase reordering commits and dropping one, pop one of my stashes
> working with code becomes a fluent experience, rather than fighting with your tools
I also do this regularly, but on my terminal. I don't feel like I'm fighting the git tools. Is this a common experience?
I enjoy using git GUIs as well, especially for visualizing branches, commits and diffs. I just don't understand why the git commands seem to cause so much trouble.
- jackcviers3 5y agoYeah, it's definitely the mnemonic single-key and terminal gui that makes magit great. That, and the genuinely low occurrence of bugs in the software.
- kmarc 5y agoI am the same. After the pandemic started and I had to witness over screen share how colleagues "use" (fight) git with all sorts of GUI tools, I had to realize that no GUI can be good enough while one doesn't understand git, or, even worse, it can be contraproductive, because people using these GUIs _think_ they understand, but they don't. I even ended up creating a (tailored) 2x90min git course... All that said, I heard magit praised so many times, I still have some hope that it's really as good as its reputation. (Tried fugitive, which is the vim-world's answer to magit, even learned it properly but realized I always juzt <C-z> to the terminal and do stuff with the cli)
- matheusmoreira 5y agoI gained a better understanding of git through this document: https://eagain.net/articles/git-for-computer-scientists/ https://eagain.net/articles/git-for-computer-scientists/ I'm not a computer scientist and I think it's understandable. Everything became a lot more clear in my mind once I understood the inner workings.
- ThaJay 5y agoThat's a really cool article. The wording could be a lot simpler but the important part is that it does not abstract the concepts. They don't need to be abstracted because they are really simple. Situations can become very complex, especially when someone does not know what they are doing. Developers need to learn the priciples without lies and overzealous simplifications. If you know what's going on it's a lot more doable to not end up in a super complex situation, but not a lot of people have a really good explanation of git even if they understand it very well themselves.
- yissp 5y agoThe underlying model of git is not too hard to understand, and is actually pretty elegant. There are a number of good explanations online, including the one you linked. The git tool itself, though, often operates at a much higher level of abstraction. I think that's more where the reputation of being hard to learn comes from. For instance, you'd probably need to write a paragraph or two to explain what "git checkout <branch>" does in terms of the actual object store. Add to that that the CLI is poorly designed - many commands have misleading names, a given command will do completely different things depending on the flags, there's a lot of implicit / counterintuitive behavior, and so on. See https://stevelosh.com/blog/2013/04/git-koans/ https://stevelosh.com/blog/2013/04/git-koans/ for some funny examples.
- beermonster 5y agoThis free book[1] is authoritative and explains Git very well IMHO. https://git-scm.com/book/en/v2 https://git-scm.com/book/en/v2
- GlennS 5y agoWhy would I use magit over the git CLI? 1. Discoverability. It'll display the contextually relevant options and commands at most points. By using magit, you're learning the git CLI commands at the same time, including commands that you'd normally never come across without a comprehensive read of the manual or release notes. 2. Fewer keypresses. Also, extra shortcuts for some common operations. 3. The bits that CLIs aren't very good for: staging and unstaging pieces of files, viewing conflicts. (I do still use the Git CLI a lot of the time too.)
- jwr 5y agoI think (2) is why I use it, it's just much faster. It doesn't let you skip over understanding Git, it just makes you work faster. I also think that the experiences of: * looking into a stash and applying only selected changes from it, * browsing all your changes and staging only some of them, * quickly killing changes that you simply want to drop, e.g. not commit and remove from your edits are much slower when using the command line.
- digikata 5y agoI tend to avoid using stash in that fine grained way because branches are cheap in git, and you get a rich set of operations using a local branch to stack up unorganized code changes. Rely on stash on only very quick setting aside of work then returning to it. If I stash and find it needs to live longer than that - I’ll stuff it into a named branch.
- deleted 5y ago[deleted]
- mplanchard 5y ago1 is really true. Magit is how I learned about workstrees!
- kmarc 5y agoSounds like the same for which I started using (and then eventually abandoned) fugitive. Staging part of files is the only thing I found hard with cli but then fugitive or simply git difftool helps with that too (using vimdiff) For everything else I defined my own git aliases (git graph, git mr, etc)
- weaksauce 5y agoMagit is absolutely fantastic and it reduces friction, discoverability and joy. rebasing is easy. commiting is easy. staging is easy. discovering is easy. everything is easy. it's incredibly powerful and also incredibly easy to use. it's simply the best software i've seen written in a long time. sounds like hyperbole but it's not. edit: magit is like if you spent months crafting a bunch of aliases for the command line and then made a nice little menu of all of them and committed that to memory but also has it as a popup. and even then magit is an order of magnitude better... handily so.
- rich_sasha 5y agoWhat I dislike with git terminal UI is that commands reflect the innards of git, not what the user wants to do. It also forces a deeper understanding of the innards for basic commands than ought to be necessary. Examples where undoing an operation looks totally different to doing it: - To stage a change you `add` it, to unstage you `reset HEAD` - To commit you `commit`, to undo a commit you `reset --hard HEAD^` The last example is also where you get pointed to an unsafe command for a fairly benign operation. Uncommitting is not particularly dangerous, but anything with `--hard` ought to give people a pause for thought. If you mistype it and nuke more than the last commit, that's also a bit bad - and fairly easily done. Some other examples include shenanigans around pushing and pulling remote branches. After 10 years of using git, I still need to google it each time. I think these commands are an accurate and reasonable representation of its inner state, but IMHO users should at least have the option of being somewhat isolated from it. Git is not a tool for algebraic manipulations on directed graphs, it is a version control software. It has to be said, to git's credit, that although the commands are confusing to some (myself included), the tool works very well. I wanted to like mercurial more, but ended up going back to git, as much as I dislike the UI.
- leephillips 5y ago“ - To commit you `commit`, to undo a commit you `reset --hard HEAD^` The last example is also where you get pointed to an unsafe command” Who pointed you there? If I want to undo my last commit, meaning the commit itself, not the changes to my file tree, shouldn’t I say `reset --soft`?
- rich_sasha 5y agoMy bad, misgoogled. But this in fact reinforces my overall point. I don't want to be messing with `reset`, hard or soft. What is `reset`? [I now know because I had to learn, but I'd really rather not]. What I want is `uncommit`, or something like that.
- theli0nheart 5y agogit revert is probably what you want?
- radarsat1 5y agoSame. After trying a couple of times, I haven't been able to get used to magit, and I gave up. I'm very used to the git command line interface, and magit is just too different from that. For instance, it seems to assume I want to operate only on a file, whereas most of the time I want to operate on the whole repository. I have no idea why someone would want to work like that. I found it was taking a lot of extra research to get it to do what I wanted, and I was completely confused by its choice of default behaviours, so I gave up trying. I would welcome an interactive tool that is more oriented around the way the command line tooling works, but magit does not seem to be it. I do have magit installed however, because I really like how it controls emacs buffers while using interactive rebase. But I never use the rest of it. I have no interest in trying to memorize which hotkey does what, and how to bend yet a new interface to my will (that apparently disagrees with my preferred default behaviour), when I already know the git command line.
- mplanchard 5y agoIf you start from the magit status buffer, most things operate on the repo, except file-specific commands like staging, unstaging, etc. For those, if you run the command with your cursor on the heading, rather than with it on a file (e.g. on the “unstaged files” heading rather than on a particular file), it will ask for confirmation and apply the operation to all of the files.
- kqr 5y agoMore generally, magit applies operations on whatever the cursor is on, when it makes sense to do so. This is very convenient e.g. for staging parts of a change at different granularities: I can stage everything, then unstage a file, then stage a hunk within that file. It only takes a few keypresses, compared to a long set of commands followed by dredging through add -pi.
- clojureyoureyes 5y ago> I have no interest in trying to memorize which hotkey does what, and how to bend yet a new interface to my will you don't have to, most of the time `git subcommand` counterpart is just `M-x magit-subcommand`
- jwr 5y agoThere is nothing wrong with using git commands in the terminal. There is also nothing wrong with copying your entire tree to a different directory, diffing, applying patches by hand, and keeping track of what goes where. Those are different levels of automation for the same fundamental task, but they are all legitimate solutions to the same problem, although you might end up spending more or less time to perform the same fundamental task, depending on the level of automation.
- matheusmoreira 5y ago> There is also nothing wrong with copying your entire tree to a different directory, diffing, applying patches by hand, and keeping track of what goes where. What? There is plenty wrong with that. I've worked with people who did that. There are lots of problems with this approach. It's extremely hard to work with and it only gets harder the more people are involved. At least in git the commits have unique identifiers, everything is hashed and checksummed automatically, branches are properly tracked, etc. I've even worked with non-programmers whose version control was emailing each other files named like: Presentation final final REALLY FINAL (2) (3).ppt It was a hell unlike anything else I had ever experienced before.
- WhitneyLand 5y agoYou probably don’t feel like you’re fighting your front door when you walk out of your house or apartment also right? All that means is that git tools, and your front door, work well once you have mastered them. The ease of use and discoverability of tools over the life of their learning curve is what determines if they are a Norman door. For lots of people, using a Unix command line or Git for the first time feels like a Norman door. This is why other interfaces exist (like guis) for the same tools. What is a Normal door - 5 min Vox short https://youtu.be/yY96hTb8WgI https://youtu.be/yY96hTb8WgI
- handrous 5y ago> I also do this regularly, but on my terminal. I don't feel like I'm fighting the git tools. Is this a common experience? My big hang-up with interactive rebases is that I do them just infrequently enough that what exactly a set of choices will yield—what's going in the commit message, et c.—is something I have to sit there and reason about for a really long (by the standards of something that really is not that complicated an operation) time. I can also never keep it straight when editing messages in-line will have an effect, and when it'll be ignored (in some commands it is, IIRC, in others not? I can never remember, but either way, why the hell let me edit it if it won't do anything?) What I could really use is a live preview of what the effects of my current choices will be.
- bentcorner 5y agoI prefer to do my interactive rebases in steps, instead of all at once. If I want to rebase changes onto a different commit, re-order them and squash some of it, I'll rebase as-is first, then do another rebase and reorder everything so that squashes are next to each other (and yes, sometimes this means unnecessary conflict resolutions), then a final rebase to squash. I'll edit messages last.
- matheusmoreira 5y agoInteractive rebases are my favorite git feature. I get to pick, drop, reorder, reword, fixup, squash, split and of course rebase commits. Pretty much everything I need to create a nice history before pushing.
- sodapopcan 5y agoI like having both. I use fugitive in vim which is great for partial staging, blaming, and committing (and status). Almost everything else I do on the command line. I will also commit from the command if I already happen to be there. The one thing fugitive is indispensable for is looking at a file on a different branch right in the editor.
- waynesonfire 5y agoi agree, i do all those things using git. no reason to learn another abstraction. maybe create a few aliases to reduce typing.
- boublepop 5y ago> I don't feel like I'm fighting the git tools. Is this a common experience? Yes. Today I spent way too much time explaining to a coworker that what he was complaining “should be easy to do but seems impossible” was actually quite simple, only to spend ages explaining how git works, why he wasn’t understanding the paradigm. And after all that help what he needed to do was simply to “git checkout feature-A && git merge master” we didn’t even touch on rebasing, and it’s not like he hasn’t used git before, he had at least half a decades worth of experience working with codebases managed in git. And this is far from the first time that I’ve had to help out people with something that seems extremely straight forward to me and others who have git under our skin, but is overly complex and difficult to people who might not be experts but have worked with git for several years in a state of “minimal viable knowledge”. Git has the same problem as it’s creator, it is arrogant, and has for way to long tried to explain the fact that new users find it difficult with “well they are just dumb” instead of accepting that it needs to make its user experience and interface more intuitive. Some of these changes are finally happening now, so I no longer have to explain why “git checkout” is used for seven completely unrelated things, but there are still tons of cases where the “straight forward way” to do something is only accessible to people who have spend way too much time doing deep dives with git and fully explored all the edge cases just for the fun of it. It doesn’t help at all that googling issues is swamped with advice of “just force it” or “delete the repo and clone it again” which can cause permanent damage to the codebase, for a tool that is at its center suppose to avoid permanent damage to your codebase. No matter how stuck up some blinded advocates of the “git is and has always been perfect”-camp you are, everyone should understand that needing to give advice like “and if you have an issue don’t Google it, go see me or another git expert first to avoid loosing code history” is at its core spotlighting fundamental issues in the tool interface.
- spaetzleesser 5y ago“minimal viable knowledge" describes my git knowledge. I simple don't have time to become a git expert. After all git is only a source control tool, there are way more important things to deal with that impact our customers.
- 5y ago
- e40 5y agoI was like you for a really long time. Then, I watched someone do stuff in Magit that took longer or I struggled with to get perfect in the terminal. Took a few weeks to get comfortable, but once I did, it was really nice.
- matheusmoreira 5y agoI'd just like to say I'm not opposed to the GUIs at all. I use gitk and sublime merge a lot. They are really nice too.
- spaetzleesser 5y ago"I just don't understand why the git commands seem to cause so much trouble." To me the git command line is one of the tools that are great if you use them often. But if you use it less often it's really hard to remember the correct syntax especially since it's really easy to mess things up. (If know WPF, the binding syntax is in the same category. Really powerful but if you take two months break you struggle with the syntax). It really bugs me in git when normal things need 3 or more parameters and if you forget one of them you mess things up. Years ago I worked with mercurial for a while and I thought the commands were much cleaner and easier to remember.
- ppp_qqq 5y agoIf you know git cli very well, most of the stuff are straight forward. Most people struggle with git if they have not spent the time to understand how it works. But there is one thing I believe is still not-very-smooth in the git cli: splitting hunks. if I do interactive add in git, and I get small hunk that adds a line, deletes a line, adds another line, and deletes a line, then if I want to include only the addition of the second line, it is pretty annoying in git cli. In magit, it is basically selecting the line and pressing "s".
- matheusmoreira 5y agoAgree. I always use either gitk or sublime merge for dealing with hunks. Diffs too.
- major--neither 5y agogit gui
- sangnoir 5y ago> I don't feel like I'm fighting the git tools I don't feel like I am either - I think some people are not fans of CLI. Full disclosure: I also don't "get it" when people say they can't use tar without looking up the help/man pages. I get by with less than 10 git commands - in rough order of decreasing frequency: pull, commit, add/rm, push, stash, checkout, merge, and more rarely bisect, revert and reset.
- Dylan16807 5y ago> I also do this regularly, but on my terminal. I don't feel like I'm fighting the git tools. Is this a common experience? Trying to stash some of the changes is pretty annoying, yes. New files don't want to cooperate with stashing, and there's no way to stash just staged things like making a commit; you have to use -p.
- matheusmoreira 5y ago> there's no way to stash just staged things like making a commit That would be a nice feature!
- gpderetta 5y agoYou have to do it in two steps with --keep-index. Or use magit that has a stash index option.
- jrootabega 5y agoI used this feature enough that I forgot/never even knew that it wasn't built in to git-stash.