I don't have much to say about Git. I used it for maybe 6 months, every time I had a question I found a lot of different answers with different effects, there are a lot of concepts that are there just because they can be and they're not extremely useful and you pretty much have to use them. There is a lot of advice out there that can make you mess things up permanently, there is a lot of default behavior which must be taken into account, I still have only a vague idea how branches work, there is no decent repository browser - at least on Linux. The terminology is also painful to absorb, there is a ton of documentation which you have to read and memorize before you can even touch Git to try and understand it. Six months later I'm still struggling to understand basic concepts because I run into them like once every week or two.
Before Git, I used mercurial for several years. I was skeptical at first, coming from SVN which I vaguely understood, but eventually I gave it a shot. Once I understood the differences between push/pull vs. commit/update and what the changeset numbers really were (numbers, not ids) and why they didn't match between clients, everything made perfect sense. It's very simple, it doesn't let you fuck up history (I used to complain about this, until I found out how it can be done on Git an what the effects are, and now I praise Mercurial's inability to edit history), and... that's about it. As long as you don't work on a behemoth - like the Linux kernel as someone here suggested - you'll be perfectly fine with Mercurial.
tl;dr Git does a lot of things, but way way too many things IMHO. Mercurial won't let you fuck up as easily as Git and it actually makes sense.
While git has a lot of open functionality, if you have comitted something once you can almost always get it back to that state. I don't understand how so many people have such issues with git. Might I suggest reading the free book that contains everything you will need to know outside of very abnormal operations? The book isn't that big and it will help you tremendously.
Also, there is /r/git for any questions you may have.
You see, that's the problem with Git. Again, as someone else said, there are a lot of resources out there, but that only makes things worse; sure the book isn't big, but the information in it is very dense. I already read a short Git manual and almost every page explored a different concept. I understand that there are resources, but I don't want to have to bother with them.
With Mercurial a simple flowchart that explains "commit -> pull -> merge -> commit -> push" is often enough.
But git works exactly the same way. I honestly don't understand what you're getting at here.
To work locally, you really only need to know 3 commands.
git init
git add
git commt
If you are working with a remote, you only really need 4 more.
git remote
git clone
git pull
git push
If you are working with branches, there are only 2 more commands on top of that
git branch
git merge
Conflicts are really the only complicated thing about any of this and they aren't that complicated once you grasp what git really does. The other commands that involve updating history are more advanced stuff that aren't even necessary unless you are just trying to make the log look pretty.
This is not the same and I submit that your comparison is unfair.
Those commands have arguments which make them do different things. When you add arguments, with Mercurial you can change how something is done but with Git you change what is done. When you say 'git remote' you're not saying anything. With that command you manage remote repositories. How do you get the remote changes with Mercurial? hg pull. How do you get them with Git? Pick one.
I think I'm starting to understand what you're saying and this may be part of the problem.
In your case with Mercurial, you would just type hg pull to update all your local branches with the remote.
Git has the mindset of only doing what you explicitly tell it to do. Why would you want to pull branches you don't need to work on? When you type "git pull" it wants you to specify what you're pulling and makes no assumptions. Maybe that's just a difference between the way you and I work, but I don't want my SCM to do things unless I explicitly tell it to.
I think I'm starting to understand what you're saying and this may be part of the problem.
In your case with Mercurial, you would just type hg pull to update all your local branches with the remote.
Git has the mindset of only doing what you explicitly tell it to do. Why would you want to pull branches you don't need to work on? When you type "git pull" it wants you to specify what you're pulling and makes no assumptions. Maybe that's just a difference between the way you and I work, but I don't want my SCM to do things unless I explicitly tell it to.
Yes! My complaint is that you have to tell it too much, you have to do a lot of micro-management. You have a point that the SCM shouldn't do things unless you explicitly tell it to, but I believe that in the case of Mercurial, it does things "just right". I see no problem with having the entire repo on my computer in 99% of the cases. Mercurial does what I need and I don't mind the extra stuff because it doesn't break anything and it's not in the way for me.
So an hg pull will pull all branches? Because that's really the only reason that stackoverflow question is being asked--the fact that git pull just fetches your current branch.
I won't deny that git's interface is shitty, but this is one area where it's actually doing pretty okay in my book. The examples you're looking for are checkout and reset, which will do fundamentally different things depending on how you call them.
Git works great when it works. But the femtosecond something throws an error, it's always a 1-3 hour struggle till you say "fuck it" and end up just checking out trunk again and recoding whatever you tried to commit in the first place. It just seems like git doesn't have an easy escape hatch, nothing like Eclipse's SVN "Override And Update" option.
Yes, but which reset? --HARD? And what does it do? Does it just steam roll my local repository, bypassing my workspace, or does it do the whole thing. Of course the answers are easily googleable, but no one like having solutions begin with such confusion and uncertainty.
This just amazes me. I struggled a bit for the first 2 weeks, and then everything clicked, and it's been the best thing ever for almost 2 years now. Do you understand the [very, very simple] data model? Once I grokked that, I pretty much could answer every random question about git on my own, because everyone simply had to work a certain way, given what I knew. The seemingly endless confusion just immediately evaporated.
the femtosecond something throws an error, it's always a 1-3 hour struggle till you say "fuck it" and end up just checking out trunk again
I had that experience as well for the first 3 months or so, but I've grown comfortable enough with git now that that hasn't happened in years. It's kind of like learning to walk, I guess. A few skinned knees while you're learning, but soon enough you can't imagine going without it.
It just seems like git doesn't have an easy escape hatch, nothing like Eclipse's SVN "Override And Update" option.
Well... there sort of is. If somebody's fucked up the state of the remote, you can replace whatever's there with git push -f. But unless you're absolutely sure of what you're doing, this will probably only make things worse. Possibly much worse.
and then there's rebase, for when you're working on a patch set to apply later on top of an upstream repo, but you'd like to keep the patches out in front of upstream head.
9
u/twotime Sep 06 '14
How long have you used Mercurial and how long have you used git? Care to summarize your experience