Readit News logoReadit News
lwansbrough · 8 years ago
Adopted a git GUI years ago and haven't looked back. I get looks sometimes, but I can't help but gloat when I can stage and unstage individual lines in less than a second.

I think anyone who uses the CLI is either trying too hard or hasn't realized the beauty of a git GUI.

Takeaways:

- My commit time is usually much faster than coworkers, with higher accuracy (less frequent accidental commits, etc.)

- I don't remember the last time I made an irreversible change to the repo, or had an "oh shit" moment. And that's despite using some interesting git features.

- Staging individual files, folders, lines of code, or hunks is easy. Makes maintaining multiple trains of though / addressing bugs while working on other code a non-issue.

- It's easy to keep files uncommitted for long periods of time intentionally, without slowing down my workflow.

- It's much easier to get an overview of the changes I'm making.

swalsh · 8 years ago
I use the git CLI. I do it for one reason. I know exactly what i'm doing on it. I have nothing to prove to anyone, I'm not trying to impress anyone with my "hacker" skillz.

When I've tried GUI's, I'm not 100% sure what's going on under the covers. Sometimes they try to obfuscate things. While I'm probably not the worlds most advanced user, I know enough to know what I want to do, and how to do it. The CLI let's me do it. The GUI get's in my way.

dilap · 8 years ago
It's not anything inherent to a visual UI though, it's just that most of the UIs that exist are trying to put their own model on top of git, rather than embracing git's model.

The one exception to this I've found is GitUp (mac only, sadly), and it's excellent. It's whole model is, "what operations can I perform on this graph," which is exactly the model git has. It's great.

aldanor · 8 years ago
There are GUIs that are very close to CLI that don't try to reinvent a wheel and instead just map directly to what git does.

The best one, I think, being Magit for Emacs (if you can call that a 'GUI' given you can run it in the terminal).

If you get used to commit things by-line instead of by-file (which is generally highly recommended with git), and also clean up your history/squash things a lot, using git cli gets VERY tedious very fast; I'd rather do it in several keypresses because why not.

MonkeyIsNull · 8 years ago
> I'm not 100% sure what's going on under the covers.

This. A thousand times over. I like to see exactly what git is doing and when; I don't want any magic stuff under the covers done for me.

WhyNotHugo · 8 years ago
Same here. Regrettably, if you UNDERSTAND git, a GUI won't work for you. If you're interested in understanding it, it won't work for you either.

A GUI works fine if you want to get things done. If you like to know what goes on under the hood, it's just confuse you.

nerdponx · 8 years ago
You might want to try Sourcetree if you haven't already. I felt the same way about Git GUIs for a long time, but Sourcetree actually does a good job of getting out of my way, and has a very nice commit history tree viewer to boot.
Tarean · 8 years ago
I like fugitive - it feels like cli git without having to leave the editor. GAdd adds the currently file/selected lines, GBlame pulls up git blame information the ability to reblame, GStatus show the status with the ability to jump to/stage/unstage files and so on. Tried Magit for a while but it didn't play nice with evil.

Still hoping for a git repl that just does graph queries/transformations though.

nullterminator · 8 years ago
I use both.

Staging, especially partially staging hunks and lines when doing multiple things at once, is way easier in a GUI when you can scroll around for context and easily undo.

For everything else I prefer the command line, because it's faster and I know exactly what is going to happen. I can do what I need to do, no fighting. If I'm just committing everything, I use the CLI. If it's more complicated I use the GUI to stage and commit, and a CLI to rebase/merge/push.

STRiDEX · 8 years ago
I use sourcetree, but I would like a console feature that shows me what commands its running. Similar to sequel pro's "console" feature shows the raw sql being run.
thelittleone · 8 years ago
How about if someone made a GUI with a console at the bottom that showed the commands being executed along with results?
antoaravinth · 8 years ago
This is exactly the same reason I too use CLI. But a word of caution Git Bash on windows has some serious problem(s). I remember, I lost my commit and in reflog it doesn't show up on CLI, however GIT UI showed the same! Not sure what's the issue, but it occurred for me twice.
donarb · 8 years ago
XCode rolled out a feature that allowed you to do an interactive commit just by click on/off switches. My first use of that feature screwed up the repo by committing the wrong pieces.

No thanks, it’s CLI for me, regardless if the IDE promises git support.

CodeMage · 8 years ago
The problem, as I see it, is not with the GUIs, it's with the CLI. Just look at the `reset` command: it does several different things, depending on what switches you give it. How would you represent that in a GUI?
danmaz74 · 8 years ago
Some git guis log the git commands they execute. Just look at those.
krapp · 8 years ago
I use either the GUI on Windows or a set of batch files I wrote to automate basic things.

As long as all you're doing is pull, branch, merge and commit, I don't think it matters.

dasil003 · 8 years ago
You're entitled to your own opinion of course, but you underestimate the efficiency of the command line, especially when you already have one open for other development tasks.

I use one or more GUIs for visualizing branches, and old branch cleanup, and yes, committing single lines from hunks that can't be split.

However for everything else CLI is fairly close to optimal, including interactive adding/rebasing, and don't want to use whatever shitty editor your tool has in it, I want to use vim with syntax highlighting so I can properly format my commit messages. Even something as simple as viewing a full commit is faster in the CLI because you can just pipe it to less or send it to an editor versus whatever tradeoffs a GUI has to make to stay performant, make use of screen space, etc.

One last tool is Fugitive. This blows away anything else I've ever seen for interactively traversing history at the line level.

reificator · 8 years ago
> committing single lines from hunks that can't be split.

Could you elaborate here? Personally I've always been able to commit just the pieces I need via `git add -p`. Never had problems staging a single line before.

Since this is text I should say: I'm not doubting you, I just like to know the limitations of the tools I'm using.

DigitalJack · 8 years ago

  > Fugitive
That's interesting. I switched back from emacs to vim (neovim), and fugitive was recommended. it just looked like :commands for the normal git cli... maybe I missed something.

So even though I edit in vim, I jump back to emacs for magit for bigger commits or multiple smaller commits (where I need to see diffs to be sure I capture my changes).

I have desired something as useful in vim, but I didn't think there was anything. I'll take another look at fugitive.

PuffinBlue · 8 years ago
> One last tool is Fugitive. This blows away anything else I've ever seen for interactively traversing history at the line level.

Sorry if I'm being think, but how do you do that? Are you talking about Gblame?

nlawalker · 8 years ago
I've become a big fan of Git Extensions. I like that it doesn't try to layer its own agenda over the Git workflow, shows all the console input/output it uses, and warns me when I'm about to do something stupid, but overall I like it for the same 3 reasons that I like most GUIs:

- It's a live dashboard. A GUI gives me live, persistent information organized well on the screen. I appreciate the power of the CLI for accomplishing tasks, but I've never understood how people prefer it when it comes to simply viewing and understanding the state of something. I don't see why I'd want to run a bunch of commands to see stuff scroll by in my format-constrained terminal when I can have a live, all-up view of multiple aspects of a repo all at once, with relevant, context-sensitive commands on whatever I click on.

- It's discoverable. Most of what I've learned about git has been through clicking around in Git Extensions.

- The structure and organization of the UI helps me to understand how git operates. When I open the "Pull" dialog, for example, the way the controls in the UI are grouped and the kinds of controls that are used help me logically understand what "Pull" can do.

emeraldd · 8 years ago
What GUI do you recommend? My experience has been that GUIs are the easiest and fastest way to make a mess that can't be corrected without dropping to CLI or re-cloning. (I'm looking at you SourceTree). I've long recommended that everyone who uses git know how to use the CLI even if they don't use it regularly.
filereaper · 8 years ago
I'd like to also point out tig. "Tig is an ncurses-based text-mode interface for git"

It doesn't have all the bells and whistles of a GUI, but if you need to look at all the branches, and commits to a repository. tig is an excellent tool. tig doesn't issue any commands though, its only a browser, you'll still need to know the CLI. (essentially a ncurses version of gitk)

I'm normally in a ssh session on a remote box where my compile & run cycles happen. tig is curses based, so no X11 needed, filled in a really nice itch of mine.

[1] https://github.com/jonas/tig

neves · 8 years ago
I tested a bunch of Git GUIs. My requisites:

- Open source (and free) - Multiplataform

The one with the best usability was Git Extensions: https://github.com/gitextensions/gitextensions

It is somewhat old ugly, and open a little too much of dialogs, but the workflow really works. It guides you to make the right thing.

A great plus is that it already comes with Kdiff3, a great open source 3 way diff open source program.

kenoyer130 · 8 years ago
The Git GUI that ships with git is very good. It also shows how Git thinks (workspace/staging/commit) that most other gui's struggle with (they try to make it look more like a SVN workflow). For diffs and blame I use TortioseGit. I also extensively use the CLI for most branch actions.
welly · 8 years ago
If you're on a mac, I can't recommend Tower enough. It's a paid app but well worth the money. Otherwise Git Kraken is a foss offering that is also excellent.
gumby · 8 years ago
> What GUI do you recommend?

I really like Magit, which is a git GUI you can use without leaving Emacs. It handles 90% of my git needs and is very tightly integrated into my IDE (Emacs). I still use some shell commands (like git mv) occasionally but those are simply m-! away.

aoeuhtns · 8 years ago
Magit in emacs. Probably one of the killer applications for emacs.
Achshar · 8 years ago
I use sourcetree and it's pretty great, especially the aforementioned block-level staging.
slobotron · 8 years ago
Not the OP, but git cola works great for me.

https://git-cola.github.io/

flatline · 8 years ago
I personally switch between the command line, git gui and gitk. I haven’t yet found a suitable GUI replacement for those two.
nastysquar3d · 8 years ago
I use TortiseGit in my personal and work dev environments. It works works well. That being said, I have had to drop to CLI to fix things that were somewhat more hairy.
_pmf_ · 8 years ago
I recommend SmartGit; it's not cheap, but it's really, really nice.
nwatson · 8 years ago
SourceTree by Atlassian ... free.
mejari · 8 years ago
For any Windows users out there, I use GitExtensions, which has served me very well over the years.
Vel0cityX · 8 years ago
I use SmartGit. Way faster and more stable than SourceTree and GitKraken, in my experience.
ggregoire · 8 years ago
VSCode or Github Desktop (even if the project is on Gitlab).

Deleted Comment

LiquidFlux · 8 years ago
Not the OP, but I had come from SourceTree to GitKraken and it's a joy to use.
bolololo1 · 8 years ago
I like GitKraken
aschampion · 8 years ago
> I think anyone who uses the CLI is either trying too hard or hasn't realized the beauty of a git GUI.

Or, you know, understands and thinks in the semantics of the underlying tool and is already working in other text-based tools.

The5thElephant · 8 years ago
Or, you know, that is irrelevant when the person using a GUI makes fewer errors than those who aren't (which has broadly been my experience as well).

Even someone who perfectly understands git can make a typo or have a brain-fart of a day. A GUI significantly reduces the chances of something like that for all users.

Sometimes dev obsession with tool purity does more damage than good.

loup-vaillant · 8 years ago
A well made GUI conveys those semantics more clearly than the default command line interface. Automation is easier from the CLI, but I wouldn't be surprised if a GUI turned out to be best for manual interactions.

(Note: I use the CLI almost exclusively.)

neves · 8 years ago
Conflict resolution in a GUI with 3 way merge really beats out a command line.
Tobba_ · 8 years ago
Doesn't really make the interface any less crap; though I've yet to see a GUI that didn't shell out to the command-line interface (which almost always makes them very unreliable).
cookiecaper · 8 years ago
Yeah, I would guess that the parent commenter has a heavily graphical workflow based out of a big honking IDE like IntelliJ. For people doing development in a console anyway, it would take more time to start a git GUI and wait for it to launch than to be done committing and pushing from the CLI.
minitech · 8 years ago
> I think anyone who uses the CLI is either trying too hard or hasn't realized the beauty of a git GUI.

Nah, it’s just a lot easier than you make it out to be. GUIs are fine too, but if you read the documentation and don’t just memorize a fixed set of commands there’s nothing dangerous, slow, or inconvenient in going about a standard workflow using the CLI.

And yes, lots of people don’t have time for this. Totally okay. Don’t generalize to “anyone who uses the CLI is trying too hard”.

lillesvin · 8 years ago
My biggest issue with a GUI is that most that I've seen introduce new terms for various stuff, e.g. "sync" in VS Code, or "revert commit" (in Source Tree maybe?) — there's no Git command called "sync" or "revert", so I'm not immediately sure what they do.

In a CLI I know exactly what's happening.

That's just my opinion though. If people feel comfortable working in a GUI all the more power to them.

autarch · 8 years ago
Git does have a revert command.
Alupis · 8 years ago
> no Git command called ... "revert"

Maybe not in the way Source Tree uses it, but there certainly is[1]! I've had to use it a few times.

> git-revert - Revert some existing commits

[1] https://git-scm.com/docs/git-revert

joonoro · 8 years ago
I like Magit because it doesn't try to hide git while still giving all the advantages GP mentioned https://magit.vc/
bootcampjs · 8 years ago
I work with a lot of people who have no idea how git actually works and it is infuriating. They all use the git desktop program, and almost every time I get called over to help, it’s because they didn’t sync or refresh or whatever the hell it does.

If you don’t have a good mental model for git, you’re gonna have a bad time.

Cthulhu_ · 8 years ago
I don't trust GUI clients; it's easy to not be able to discern the current status, easy to just commit all changes, some of the clients don't respect the pre-push hook, and I've seen other colleagues who have no clue what they're actually doing end up mixing pull and pull --rebase, somehow managing to make duplicate commits with slightly different contents and not having a clue what's going on.

Don't use clients if you don't even understand the basic git workflows. And those usually don't support the advanced oh shit situations this article is about.

lwansbrough · 8 years ago
> it's easy to not be able to discern the current status

Probably a failure of whatever UI you're using. I manage just fine.

The common statement from CLI types is that "it's just whatever you're better at using" which is true conceptually, but practically, again, CLI users make more mistakes either from fat fingers or lack of understanding of git.

Understanding git conceptually from a UI point of view is easy. You don't even have to have a full understanding of git to be effective at using it, if the UI is good. I'm shit with the git CLI, but I understand what git is doing.

Yes it's easy to do dumb shit in a GUI, the same is true for CLI. In fact, it's less likely that there'd be a button for doing something dumb than it is that a git novice would find some command on StackOverflow and attempt to use it without fully understanding the ramifications of it.

rcxdude · 8 years ago
I've felt a good GUI would make using git far more intuitive, but I've yet to find a good one. They all seem to fail on one front or another (too hard to use, don't expose enough functionality, attempt to enforce one workflow, aren't available on platforms I want, are slow/resource hogs).

Usually I use the included gitk to view the repo, and the CLI to manipulate it.

Deleted Comment

rhodysurf · 8 years ago
For the most part using git is like five commands and it is definitely fast to use them from the command line if you have some sort of git understanding
emodendroket · 8 years ago
Which do you use? I'm generally pro-GUI (I love Postman, for instance, and don't use curl much) but my experience with git GUIs has been that they were kind of half-baked and will not do what I expected, leaving me with a difficult-to-understand mess to clean up.
MaulingMonkey · 8 years ago
> I think anyone who uses the CLI is either trying too hard or hasn't realized the beauty of a git GUI.

I've suffered a lot of git GUI bugs. The admittedly large repositories I sometimes deal with cause things to hang and stall, breaking my flow. I keep filing bug reports - truncated diffs because new files were "too large" (presumably someone trying to fix the hang and stall issue), a client that only renders the top half of the window consistently when on a portrait 4K monitor, etc.

The git CLI is simply second nature enough to me at this point that waiting for a GUI to load, refresh, etc. is rarely faster. It does happen, but it's not the common case. Getting a good summary of a set of changes is sometimes one of them. Picking individual hunks/lines is sometimes another - although I prefer to commit with such frequency when using git, that it's extremely rare I have changes that belong in different commits.

Then, looking at perforce, I'm finding more and more cases where I'm dropping out of P4V and into command line tools. Any kind of mass move/edit seems easier to do through the command line. Command line diffs were way easier to review than P4V's file based diff interface when I had changes involving 1 or 2 line tweaks spread across dozens to hundreds of files (such as verifying function rename changelists didn't accidentally pick up other changes.)

I think anyone who's swayed by the beauty of a git GUI has much more patience than me.

"Sourcetree (Not Responding)" - I typed this out while waiting for my Visual Rust tab to focus. Euhg.

I could've made a commit from the command line in that amount of time.

madeofpalk · 8 years ago
I've found my sweet spot is using both a GUI (Github app, to be specific) and a CLI.

GUI for partial commits and reviewing my change, and then command line for basically everything else (merge, checkout, branch, etc).

rectangletangle · 8 years ago
I've tried out a few different GIT GUIs, and never really took to any of them. Settled for using the CLI + many BASH aliases. Anything I do frequently gets a concise alias to minimize typing. I have relatively short fingers, and I'm admittedly a pretty poor typist, so I really emphasize the concise part. Pretty much all the aliases are write only code. I do this for pretty much every other complex CLI application too, e.g., Docker, Heroku, AWS. A little abstraction really speeds up using the CLI. Aliases are my favorite feature of BASH, I think they've saved me literally months of typing at this point in my life.

Here's a few handy ones:

  alias currentbranch='git rev-parse --abbrev-ref HEAD'
  alias gpush='git push origin $(currentbranch)'
  alias gsync='git pull origin $(currentbranch)'

  alias ga='git add -A'
  alias gc='git checkout'
  alias gcm='git commit -m'
  alias gca='git commit --amend'

  # and my personal favorite (list recent branches)
  alias gb='git for-each-ref --sort=-committerdate refs/heads/ --format="%(HEAD) %(color:yellow)%(refname:short)%(color:reset)" | head -n 20'

tylerhou · 8 years ago
My version of gsync is `git pull --rebase origin ${currentbranch}`, since I hate having random merge commits.
kendallpark · 8 years ago
I use a git GUI for staging commits, but the CLI + text editor for everything else (and no aliases). The CLI is universal--I can go to another dev's computer and get them out of rebase hell without learning their particular git GUI interface. Knowing the CLI by heart is also useful if you ever have to use git server side through SSH. I have found that the CLI fits into my workflow better than the GUI for everything except staging.
sigi45 · 8 years ago
I work very well on a cli. I can do partial adds faster than you and don't had any 'oh shit' moments for a few years.

I do not care if someone is using a gui.

My takeaway: - If i can use git on an cli, i can use git on any server with an cli. I do need this for when i use git on my ansible maschine or on my home media server or when doing something with build infrastructure (jenkins -> git -> cli)

marssaxman · 8 years ago
Past experience with GUI frontends and other sorts of simplifying interfaces for version control tools has left me extremely reluctant to use anything more than git's out-of-the-box command line, despite its execrably wretched, unlearnable inconsistency. When things don't make sense with git, I can at least compare notes with coworkers, or search the web and find many discussions where other people have been similarly confused, and received useful advice. If I'm using some custom frontend interface, on the other hand, there are inevitably going to be situations it doesn't handle where I have to fall back to the command line, which I won't remember anything about because I will not have been using it, nobody else on my team is likely to be familiar with the tools I'm using, and discussions on the web are likely to be scarce. Better to just absorb the ongoing pain of git's terrible interface for day-to-day tasks so that I'm not completely hosed when things inevitably go wrong.
Balero · 8 years ago
Additionally you can always use the command line if you need to. I use a GUI for 99% of what I do, then use the CLI for what I need it for.
dlwdlw · 8 years ago
I wouldn't say "anyone" is trying to hard but I have seen a lot of people who immediately disregard guis as soon as they internalize that the cli is more difficult. Reasons include wanting to be "badass" or "smart". Yet many also do not care about how got differs and basically ask "how do I save" and proceed to revolve their entire workflow on a few copy pasted or memorized commands.other they hear how "rebase" is only for "smart" people...

On the opposite side gui users can often be unaware of the actual model and instead be working with imperfect internal models with be GUI being a crutch.

In both cases there is lack of desire to learn but I'm often more sympathetic to the latter where people want just enough information to do their work well as oppossed to the former who often make things harder than they have to be in all areas and have lost touch with true expertise in favor of appearance of expertise.

Deleted Comment

chiefalchemist · 8 years ago
Which Git GUI are you using?

The GUI is said to be a major leap forward in human conputer usage, in the context the CLI just strikes me as either (elitist?) jargon, or brogrammer bravado. In either case, not really a step forward but certain macho. I still don't get it.

repsak · 8 years ago
I use https://github.com/jonas/tig for interactive staging and git CLI for everything else. Best of both worlds and I don't have to leave the terminal.
aglionby · 8 years ago
+1, not having to use a mouse is great. I also use zsh's inbuilt git aliases [0] which I can't recommend enough -- I've found using git CLI without them a pain now that I'm used to them. These together have me productive and happy.

[0] https://github.com/robbyrussell/oh-my-zsh/wiki/Plugin:git

dozzie · 8 years ago
> I think anyone who uses the CLI is either trying too hard or hasn't realized the beauty of a git GUI.

Or just couldn't be bothered with leaving terminal. I refuse to reach for mouse for any repository operation when everything else I do from console.

Pxtl · 8 years ago
I use both - to me the big advantage of getting used to GIT CLI is that you learn the tools to handle uncommon operations and automate tasks, which the GUI doesn't give you. When you need to start piping stuff through grep, for example.
cytzol · 8 years ago
GUI user here. Genuine question: when would you need to pipe stuff through grep? I get it would be a rare situation, but I can't think of one.
pkamb · 8 years ago
In addition to better staging and committing, I love my git GUI for allowing me to easily see and work with every past commit.

Right click on any commit and I can create a new branch there, copy the SHA, do a mixed reset to that location, rebase on it, etc. SO much easier to visualize the actual tree of commits you're working with.

I'm sure some people do do all that from the command line. But every CLI coworker of mine has really only known the basics of branching and committing. The GUI unlocks the repo and all of its branches and commits as something you can play with and explore.

ashelmire · 8 years ago
Git is, imo, way too simple to require a gui. How long is it taking you and your coworkers to make commits? git commit -am "message" (or add the files you want with git add, then commit); git push; git pr -m "message". The longest part of that is coming up with a good commit message. A gui isn't going to stop people from making mistakes because the mistakes aren't from complexity of the command line, they are from committing things you shouldn't, which will happen regardless of whether or not you use a gui.
quicklyfrozen · 8 years ago
For me, using a GUI makes it much less likely I'll commit the wrong changes as I can quickly review each staged file across the entire tree before committing, and also see if there are unstaged changes (including new files which was often the bane of an SVN workflow) which need to be included.

I typically use git gui to commit changes, the cli for other operations, and occasionally source tree to visualize branches and compare with remote repos.

B_612 · 8 years ago
The Git UI that comes with intelij can do all the essentials git statements and has a console that logs everything it is doing.

And you can also learn useful things by reading the console sometimes. There is no magic.

outworlder · 8 years ago
"- It's easy to keep files uncommitted for long periods of time intentionally, without slowing down my workflow." "- My commit time is usually much faster than coworkers, with higher accuracy (less frequent accidental commits, etc.)"

Do you mean that as "not committed", or "not pushed"?

If you mean not committed, then why is it a good thing? You should be committing often. Then you push after you are satisfied. It is much easier to revert mistakes that way.

inferiorhuman · 8 years ago
Once upon a time I found a git GUI that I liked (SourceTree). Then Atlassian bought it and pushed their cloud nonsense on me so hard that I just gave up and reverted back to the command line. Eventually I bought the O'Reilly book and figured out how to do the neat things that SourceTree would let me do. Only this time the GUI wouldn't get borked while trying to stage individual lines.

I haven't looked back because I haven't found the need.

lambda · 8 years ago
I'd consider myself an expert on Git, and I use a GUI of sorts for the vast majority of my Git work: Magit in Emacs.

It has many of the advantages that you describe; makes it easier to get an overview of what's going on, makes it easier to stage individual files, folder, lines of code, hunks, etc.

There are a couple of cases in which I need to fall back to the Git command line, but it's not very often, and I do find it substantially improves my life.

sb8244 · 8 years ago
I'm in such agreement here.

I often see files that clearly shouldn't have been committed. I always bring up using Sourcetree or something else, but everyone seems to think that it's okay the way it is. I can't force it on them and to each their own. It is really frustrating though, because there's this stigma against using a git GUI, but the end results of using one are (in my experience) significantly better.

Deleted Comment

CruiseDevice · 8 years ago
I don't know how much difference does it make using gui or cli. When i was interviwed for my first job i was asked questions on git. And they asked if i use gui or cli.I think they wanted to know if i really know how to use git through cli. I never used gui for git, maybe i will use in the future. I think Ohsitgit is a good resource which i was trying to find on internet for so long.
drdrey · 8 years ago
It doesn't have to be an exclusive or. I use the CLI for most things, but a GUI when it makes sense (like you mentioned, staging specific hunks). I find that for the most part, my CLI workflow is so straightforward I rarely get in an "oh shit" moment: git pull, git co -b featurebranch, a series of git ci -av, and a git push to open a pull request.
crescentfresh · 8 years ago
There's a git GUI??

Seriously though, I'm somewhat new to git and any problem I come across (which are many as a new learner) are solved with command line options. I'm not even familiar with the best GUI options out there and have been trying to learn what seemed to be the "standard" way of git'ing.

chis · 8 years ago
I’m a big fan of Gitkraken. Great for doing common actions in one click, and graphically viewing history. It’s crazy how negatively people judge me for using it though. It’s like telling someone I prefer Microsoft Word as my IDE.
chuckdries · 8 years ago
Seconded for a GUI. I've been using gitkraken for almost a year now, never looked back.

(full disclosure: as of last week I actually work for the company behind gitkraken but I started using it far before I realized they were local)

machiaweliczny · 8 years ago
On mac I can recommend Gitup. It's fast and easy. Also vs code has quite nice git integration. I just use it for making commits though. Everything else is faster from CLI.
foobaw · 8 years ago
Android Studio has a git UI built-in so it's really useful.
TomK32 · 8 years ago
I always do `git add --patch`, it's very precise and I can edit lines before staging them. I really don't see why someone would work without it (or a GUI).

Deleted Comment

zxy_xyz · 8 years ago
I use the CLI because I don't currently work on any group projects.
justbaker · 8 years ago
I’ve only seen the opposite effect in practice. My odd look as well.
hyperpallium · 8 years ago
So... which git GUI are you using?
qaq · 8 years ago
Which git GUI are you using?
firemelt · 8 years ago
What git gui? Git kraken?
collinmanderson · 8 years ago
Which GUI do you use?
mmmpop · 8 years ago
> I think anyone who uses the CLI is either trying too hard

Why do you think it's okay to share this opinion?

lwansbrough · 8 years ago
Because this is a forum and nothing I say matters.
ksk · 8 years ago
The problem of course is the question - What gives anyone a right to do anything? What gives you the right to police the comments? What gives me the right to question your questioning? Meta-discussions always get sidetracked..
Angostura · 8 years ago
What makes you think it is not?
falcolas · 8 years ago
A git off my lawn moment: Every time I see someone complaining because they have to dive into the reflog to fix their own mistake, all I can hear is "I was operating my table saw without using a push stick and can't understand why I lost a thumb".

Friends don't let friends (especially those who don't learn how to use their tools) rewrite shared git history. If you don't understand rebase, amends, etc can do to your (and everyone else's) repo, DON'T DO IT.

AlexCoventry · 8 years ago
On the other hand, doing it is the only way you're going to learn. Just do it in a safe environment, with a snapshot of the repository.
jsmthrowaway · 8 years ago
Yep. That is the important tip, right here.

    $ pushd ..
    $ cp -a my-project my-project-before-I-did-git-surgery
    $ popd
Then relax. This is extremely important before playing with nasty Git surgical tools such as huge rebases. Borked it up?

    $ pushd ..
    $ rm -rf my-project
    $ cp -a my-project-before-I-did-git-surgery my-project
    $ popd
Undo is a great thing, and it's also important to triple check the entire state of the repository before you push, because pushing is basically committing to whatever surgery you've done. If you're having to fix stuff with -f, you're going to run into trouble; try to avoid -f ever.

flowardnut · 8 years ago
practicing safe version control is better than abstinence
rkangel · 8 years ago
This is a place where Mercurial wins out. Hg has the concept of phases that makes it much harder to screw up rewriting history:

https://www.mercurial-scm.org/wiki/Phases

falcolas · 8 years ago
Replacing a table saw with a circular saw (bad analogies abound) doesn't remove the opportunities for losing appendages. Especially for those who don't learn how to use the tools put in front of them.

"It is impossible to make anything foolproof because fools are so ingenious."

Yes, Git is a sharper tool with fewer blade guards than other version control systems, including HG. That sharpness and relative lack of safety mechanisms, however, lets you do things you can't in other systems. The real problem is that folks use these tools without attempting to understand them and cargo-cult onto a workflow which leaves them open to screwing things up.

To continue the "git off my lawn" moment - I've had to use the reflog exactly zero times in the past few years, despite using rebase locally on a fairly frequent basis (and sadly remotely to fix other's bungles as well). This is only because I respect git for its sharp edges, and when it comes time to re-write history with rebase, I work carefully.

leggomylibro · 8 years ago
Reminds me of a time I saw a funny Makefile mistake. SRCS contained both .cpp and .c files, and someone copied a recipe that only replaced .c ones.

Then they used the resulting variable in 'make clean'. That was more of an, 'oh shit, git pull' sort of thing though.

azernik · 8 years ago
I use the reflog all the time to fix my own rebase mistakes; it's just on rebasing I've done locally, and where the results haven't made it out to a shared repo.
Groxx · 8 years ago
Rewriting shared history fits the metaphor pretty well.

But you can still chop off your thumb in your local history, and that's safe to fix - you just have to know where the duct tape is.

swalsh · 8 years ago
rebase can be dangerous, but so productive. I think it's important to teach new devs how to properly use it. Especially if you're working in a continuous deployment environment, where you may need to quickly revert something.
falcolas · 8 years ago
Reverting something does not require a rebase. It requires an aptly named command "git revert". Additionally, in the event that a deployed feature needs to be reverted, any halfway decent change management policy will want a history of what you reverted and why; a git revert commit can show both very cleanly.

And, frankly, since all rebase does is re-write history, I fail to see how it's inherently productive, especially in the context of re-writing the history of previously shared commits. Yes, it is capable of cleaning up and reducing the number of commits you have to read through when looking at history, but that's such a rare event that optimizing for it (especially by normalizing dangerous commands like `git push -f`) seems, well, premature.

madeofpalk · 8 years ago
driving can be dangerous, but so productive. I think it's important to each new adults how to properly use it.
Nullabillity · 8 years ago
You already have git-revert, for reverting commits without rewriting history.
greysteil · 8 years ago
Nice. For anyone who hasn't see it, Flight Rules for Git is even more comprehensive: https://github.com/k88hudson/git-flight-rules
james-skemp · 8 years ago
I like this. I was trying to do something similar with my Git cheatsheet - https://gist.github.com/JamesSkemp/15fcf0147cb85bb633bf - but it doesn't have the kind of organization I'd like due to the limitations of using a Gist.
taoistextremist · 8 years ago
I'm planning on making a hard push for git on the team I just joined (that isn't using any VCS). This and OP are going in my bookmarks.
Cthulhu_ · 8 years ago
> I'm planning on making a hard push for git on the team I just joined

You mean a force push. `git push --force` is one of my favorite commands. I've aliased `git yolo` to `git push --force --no-verify`.

pc86 · 8 years ago
I'm genuinely curious how they manage source without any VCS. Is it just a bunch of zip files for old versions?

No judgment, nobody is born knowing this stuff, just that I'm surprised to hear this is still out in the wild.

herogreen · 8 years ago
In three years of using git I believe there is a single bad command that I could not undo: `git checkout -- somefile` The second worst thing I did is losing a commit in a `git rebase -i` but I was able to find it back with `git reflog`. Which makes me think that git is really well designed.
anton_gogolev · 8 years ago
If by "designed" you mean "picking a content-addressable DAG as an underlying data structure", then yes, it is really beautiful. If you mean "provide a sane level of abstraction over said data structure", then hell no!
jimktrains2 · 8 years ago
I think git provides a sane level of abstraction.

I don't think it provides the most consistent UI or helpful help, though. Once you move away from "learning git commands" to "learning how git works" and kind of figuring out which parts the commands refer to has helped also. That's still terrible though.

tonetheman · 8 years ago
Preach on brother!!!!!
_pmf_ · 8 years ago
Beautifully stated.
nvahalik · 8 years ago
I recently had one of those holy-crap-what-did-I-just-do-I-lost-everything moments... But then realized that my scrollback had a list of files and my IDEs (PhpStorm and WebStorm) both kept _local_ revision histories and I was able to restore everything I had done.
maaaats · 8 years ago
I've been saved by the local history in IntelliJ more times than I would like to admit, heh.
Cthulhu_ · 8 years ago
I've had a few cases where I accidentally removed a local change before committing it; using Time Machine you can still recover some files then. I wish more editors had built-in support for it, if you're trying to restore a local file, macOS's TextEdit has support for Time Machine.
nsxwolf · 8 years ago
This combined with Time Machine backups means I haven't lost source in years.
jimktrains2 · 8 years ago
Learning about the reflog just changed everything -- it removes all fear of "loosing" anything but uncommitted work.

In a similar vain to `git checkout`, `git reset --hard` is also an excellent way to loose uncommitted work.

humblebee · 8 years ago
When I know what file I'm missing a commit from, I usually end up using `git log` instead.

    git log -p --all --first-parent --remotes --reflog --author-date-order -- somefile
I accidently screwed up a rebase and dropped a test file. It managed to get merged as a blank file (always review after rebase!), I noticed a few days later when a PR was passing which I swore would of failed some tests I had written. Since then I couldn't exactly remember when I made the commit to the file, so trying to search through reflog became difficult. The above command makes it pretty easy as it will show you every change made to a file.

0xcde4c3db · 8 years ago
I'm a big fan of 'git checkout -p'. Even if you nuke a hunk you actually wanted, it's not actually gone until it falls off your scrollback buffer.
Yokohiii · 8 years ago
When in doubt either:

* commit to an itermediate branch as storage

* git stash && git stash apply (repeat last to recover stuff)

nathancahill · 8 years ago
git stash pop is often nicer for temporary stuff.
philjohn · 8 years ago
The underlying system is well designed, but a user interface that allows you to get into a point where you can hose a repo is anything but.
runeks · 8 years ago
The user interface should allow you to do anything you want, but warn you properly. In my experience, this is what git does if you’re about to do something dangerous.

How can you blame git for deleting stuff if you blindly pass --force to it?

blibble · 8 years ago
you can always get back to what you had before unless you try really, really hard to destroy data

git reflog is your friend

sfink · 8 years ago
You could also use an alternative CLI for git. My preferred one is hg-git.

I'm sort of kidding, but not really. By using it, I can operate on a git repo using the mercurial CLI, which I am more comfortable with and have built tooling around.

Once you have the extension installed, it's a matter of prepending 'git+' to the beginning of eg a github url to clone it, and then you can use native mercurial commands.

Obviously, this is an extra layer with all of the problems that involves (eg you're going to be managing git branches through an hg interface. Which works surprisingly well most of the time.) So this makes NO SENSE WHATSOEVER unless (1) you are comfortable with the hg interface, (2) you aren't that comfortable with the git interface, and (3) you don't need to do complex operations that would require thinking through the layers of what is happening.

Honestly, though, if I want to contribute to a github repo, this gives me everything I need 95% of the time. So far, the only time I ran into trouble was when the active branch was renamed in the github repo. Things got very tangled up, and I had to re-clone and import my patch stack. Judging by the number of people talking about making "backups" of git repos in this comment section, it doesn't sound like that's an unexpected operation in git-land. With mercurial's immutable and append-only nature, I very very rarely need to do this, so it felt kind of awful.

(Admittedly, my main hg repo that I work on is 6GB and I'm normally near the limit of my disk space, so my habits don't really match your typical megabyte-sized github repo in some noncompiled language.)

mFixman · 8 years ago
Honestly, a lot of what's wrong in git is that people seem to mostly memorize or copy-paste a finite amount of commands, and when something goes wrong they are completely lost unless they can find a way to copy-paste a solution.

Instead of saving a 6 command list for some use cases, why not just get used to the simple but kinda unintuitive way of how revisions and branches work? If you know that, you can solve any problem with `commit`, `checkout`, `reset`, `reflog`, and occasionally `cherry-pick`.

CJefferson · 8 years ago
Quick quiz, what does 'git checkout x/y' do? I am aware of users hitting at least 3 interpretations.
Nimitz14 · 8 years ago
I'd say it changes your code to match that of a branch in your local copy of the repo.
ufo · 8 years ago
I think you already answered your own question. It is very hard to get comfortable with things if they are unintuitive :)
compiler-guy · 8 years ago
The fact web pages like this exist, and are popular, and make it to the top of Hacker News is all you need to know about git's ease-of-use and mental model.

That Perforce and SVN don't get such things should also tell you something.

(Which isn't to hate on git--it's a great tool.)

forrestthewoods · 8 years ago
Threads like this are a nice reminder of how nice it is to use Perforce. There's no such thing as getting yourself into a bad situation. Not even for artists or designers.

Git has eleventy million blog posts trying to explain how simple it is to use. That's a clear sign that it is, in fact, not simple or easy.

accatyyc · 8 years ago
Reminds me of all articles attempting to explain how simple monads are
yes_or_gnome · 8 years ago
The SVN and P4 articles exists (just google for "svn mistakes" and "perforce p4 mistakes"), but either 1. nobody is sharing them to HN or 2. they do and nobody cares to vote them up.

Unrelated topic (falling cats), same logical fallacy: http://www.radiolab.org/story/102525-vertigo/ (Starting around 14:20)

compiler-guy · 8 years ago
“Nobody submits them, or nobody cares to vote them up.”

That should tell you something: these articles don’t resonate with the crowd. That should tell you something.

tnolet · 8 years ago
Good thing HN doesn’t have memes, otherwise I would post one of those bears confessing “I’m a software engineer with 19 years of experience and I still don’t really understand git”.

Silliness aside, I guess Git suffers from the trait that it is very hard for many people to internalize and visualize how it works in their heads. Totally different but related: the Azure CLI is for some reason 10x easier to work with than the AWS CLI, while I’m 10x more experienced with AWS. I guess CLI design is also design.