News for hackers. Stuff that matters.
Re:Some bad Git situations and how I got myself out of them by noufalibrahim on Friday September 09, 2016 @02:15AM (#12459974)
I don't know if this post was intended as humour or a way to vent out some frustration but in my experience, this path of treating git as "spell X solves problem Y" will always break down.

Version control systems are an important part of the programmers toolkit and it's worth investing a little time to get the fundamentals right.

Sure git is not the friendliest of beasts but what it lacks in interface, it more than makes up in internal consistency and trying to learn it "inside out" is a better long term investment than having a list of ways to solve "git problems".

Re:Some bad Git situations and how I got myself out of them by mcv on Friday September 09, 2016 @03:39AM (#12460273)
I think the biggest problem people have with git is that you can't and shouldn't want to change shared history, and yet git provides some tools that suggest that maybe you can.

It's better to accept history as it is, and fix the problem with reverts, cherry-picking and new commits. History won't be as pretty or clean, but it will reflect what actually happened, which is what history is, after all.

The biggest trick to understanding git is to learn to think in commits rather than file content. If one branch has a commit and the other branch doesn't, merging them will mean that the commit is there. If one branch has the commit while the other branch has the commit and a revert for that commit, merging will mean it will be reverted.

Same goes with pushing. If you reset locally to before a commit that you already shared, that commit returns on your next pull. If you revert it, it will stay reverted.

The most dangerous thing git can do, is rebasing. Rebase changes history. This is fine if it hasn't been shared yet (you commited a new change and try to push, but remote changes need to be pulled first, so rebasing is fine). Rebasing is not fine if the commit has already been shared, through a different branch or a different remote repository, for example. In that case, you need a merge.

As pretty as rebase can make your history, you should really only use it when you understand what it does. If you don't, stick with merge.

Re:Some bad Git situations and how I got myself out of them by l0b0 on Friday September 09, 2016 @04:57AM (#12460539)
`git rebase -i` by default rebases only back to the first commit you haven't shared (at least that's how I interpret the actual behaviour). This is a great default - it's the simplest way to change history and at the same time powerful without being too dangerous.
Re:Some bad Git situations and how I got myself out of them by ZeroGravitas on Friday September 09, 2016 @05:34AM (#12460670)
Ah, interesting. I'd noticed this behaviour but hadn't conciously thought about it.

The docs say:

All changes made by commits in the current branch but that are not in <upstream> are saved to a temporary area. This is the same set of commits that would be shown by git log <upstream>..HEAD

Re:Some bad Git situations and how I got myself out of them by mcv on Friday September 09, 2016 @07:33AM (#12461171)
If they're not in upstream but they are in another branch, it's still dangerous.
Re:Some bad Git situations and how I got myself out of them by majewsky on Friday September 09, 2016 @08:34AM (#12461526)
Well yeah, sometimes this power is needed. For example, I might need to do a rebase over published history to remove a patch that was found to be a copyright infringement.
Re:Some bad Git situations and how I got myself out of them by phaemon on Friday September 09, 2016 @09:50AM (#12462145)
I don't understand. Could you give an example?
Re:Some bad Git situations and how I got myself out of them by skissane on Friday September 09, 2016 @05:31AM (#12460652)
I think the ability to edit history is one of the great advantages of Git. I encourage people to use it rather than ignore it.

Cleaner history makes life much easier for those who will try to understand what you did weeks or months or even years later (including your future self).

Of course, you shouldn't (with rare exceptions) edit history you have already shared with others; but, I never found that concept, or the way git implements it, particularly hard to understand. (I will admit some of git's commands are hard to remember - I am always forgetting the difference between "git reset --hard" and "git reset --soft".)

Re:Some bad Git situations and how I got myself out of them by tech2 on Friday September 09, 2016 @04:39AM (#12460483)
> but it will reflect what actually happened, which is what history is, after all.

Recorded history is not necessarily what actually happened though, often (or always, according to some) it's an interpretation.

"History is written by the victors" - Walter Benjamin?

Re:Some bad Git situations and how I got myself out of them by falsedan on Friday September 09, 2016 @01:48PM (#12464486)
> I think the biggest problem people have with git is that you can't and shouldn't want to change shared history, and yet git provides some tools that suggest that maybe you can.

Funny, I think the biggest problem is people who refuse to understand the caveats of rewriting shared history and spread FUD about it.

Re:Some bad Git situations and how I got myself out of them by Ntrails on Friday September 09, 2016 @10:24AM (#12462480)
> If one branch has a commit and the other branch doesn't, merging them will mean that the commit is there. If one branch has the commit while the other branch has the commit and a revert for that commit, merging will mean it will be reverted.

See, I fundamentally disagree that this is what I wanted. When I merge my thing with change x into head I expect to see my changes actually go in. Not to see commits retroactively added to head. The merge was the action, not some weird rewriting of historical order of events.

> The biggest trick to understanding git is to learn to think in commits rather than file content.

Ok, I'm starting to see what you meant. (I didn't understand this until the second part and my being confused as heck)

Re:Some bad Git situations and how I got myself out of them by ewjordan on Friday September 09, 2016 @03:56AM (#12460337)
"Not the friendliest of beasts" is putting it mildly.

Git is basically Linus in a nutshell: abrasive, unforgiving, and behaving like an absolute asshole to any non-expert struggling user.

Sure, engineers should probably get to know its quirks and learn to work around them because it's now ubiquitous in the field, but let's not pretend that there's something virtuous about it. This is a piece of truly terrible software with an even worse UX that just happened to win the PR battle against its superior foes, because...Idunno, Linux, I guess?

Re:Some bad Git situations and how I got myself out of them by Singletoned on Friday September 09, 2016 @04:32AM (#12460458)
> Git is basically Linus in a nutshell: abrasive, unforgiving, and behaving like an absolute asshole to any non-expert struggling user.

You forgot "brilliant".

Re:Some bad Git situations and how I got myself out of them by ewjordan on Friday September 09, 2016 @12:19PM (#12463615)
Fair point. For all my whining, I use both Git and Linux every day, they are incredible pieces of technology, especially compared to what came before.
Re:Some bad Git situations and how I got myself out of them by TickleSteve on Friday September 09, 2016 @05:26AM (#12460631)
not necessarily better than most other good engineers...

He knows a lot about his domain, sure, but he's no god and there are a lot of areas he knows diddley-squat about.... user interface design for one!

Re:Some bad Git situations and how I got myself out of them by Singletoned on Friday September 09, 2016 @05:33AM (#12460664)
> He knows a lot about his domain, sure, but he's no god and there are a lot of areas he knows diddley-squat about.... user interface design for one!

And Einstein knew nothing about biology.

I'm sure he knows "diddley-squat" about most areas, but as long as he knows a lot about his domain then he's an expert.

And he is good at user interface design, and git is a good example of that; it's just not aimed at beginners. It was designed by and for expert users, and the interface fits that very well.

Re:Some bad Git situations and how I got myself out of them by TickleSteve on Friday September 09, 2016 @05:45AM (#12460714)
no, its not a good UI.

admittedly "expert" UIs are different from "noob" UIs, but the number of "git magic spell" followers out there mean that it isn't a good UI for the majority of people who use git.

Re:Some bad Git situations and how I got myself out of them by dozzie on Friday September 09, 2016 @06:35AM (#12460909)
Well, if you treat git as Torvalds intended it in the beginning (framework for building VCS-es) and accordingly limit the discussion to git's plumbing command set, you get a sensibly good UI+architecture that is targeted at programmers that write VCS-es.

Git being operable with a pry bar and repairable with a hammer is a good proof that in this context it's a good design.

Re:Some bad Git situations and how I got myself out of them by SmellyGeekBoy on Friday September 09, 2016 @06:14AM (#12460803)
I'm not sure why a kernel developer would need to concern themselves with UI design?
Re:Some bad Git situations and how I got myself out of them by rakoo on Friday September 09, 2016 @05:36AM (#12460678)
Hah, so just like git then.
Re:Some bad Git situations and how I got myself out of them by wkd on Friday September 09, 2016 @04:19AM (#12460409)
I'm struggling to see which VCS you deem superior, I'm assuming you are not referring to SVN, Mercurial maybe?

The learning curve to git is not great but as far as I know nobody has publicly released an option that's improved enough over git to motivate the cost of switching technology. If it's not working for you the only advice I can give is either learn it until it is actually working for you rather than being in the way or try to find a better workflow.

Re:Some bad Git situations and how I got myself out of them by pjc50 on Friday September 09, 2016 @04:26AM (#12460435)
SVN is much easier to use for the standard corporate workflow of a group of people making commits to a project which mostly advances monotonically with continuous integration.

Edit: also in a Windows environment, svn copes slightly better than git. First project we tried it on had the worst possible environment, a mix of Windows and Linux systems. Line ending nightmares everywhere.

It also took a while to work out how to kill (with fast-forward) the spurious "merge commit" you get every time someone does a pull. You don't have that with svn, you just do the merging locally when you update and it doesn't generate a commit.

Re:Some bad Git situations and how I got myself out of them by brusch64 on Friday September 09, 2016 @05:02AM (#12460552)
I've been using Subversion since 10 years or so and I've changed completely to Git, so I've got experience with it.

For me Git was really a much needed upgrade to subversion. Working with branches (testing and production, we even have some repositories with multiple testing and production branches) are working like they are supposed to do. Changing commits (oops - I forgot to add one file) before pushing them to the repository for the other users is another big advantage. Working on multiple features in parallel - I couldn't do that with Subversion.

We've nearly completely eliminated the "handcrafted" local copies with multiple half finished features since changing to Git.

And if you want to use Git as a Subversion alternative you can use it in this mode too - altough you are missing out on some good new features.

I don't want to change back to Subversion.

The only disadvantage is that SourceTree (the GUI tool we are using) is a pretty lame duck in Windows. But the command line is excellent.

Re:Some bad Git situations and how I got myself out of them by TickleSteve on Friday September 09, 2016 @05:35AM (#12460675)
So what problems exactly did you have with SVN?

branches are branches in svn or git... your process may not have been correct, but lets not blame the tools here..

modifying commits is a big no-no for me, so thats not a drawback at all, the fact that its not possible in svn is a win for svn.

Re:Some bad Git situations and how I got myself out of them by brusch64 on Friday September 09, 2016 @05:57AM (#12460751)
I really like modifying commits (as long as they are not pushed) - but I know that this is quite a controversial topic.

For one of our biggest projects branches in SVN didn't work at all.

We have multiple production, test and development branches and merge branches (features) from one branch to the other (development -> testing -> production). Sometimes we cherry pick a single commit to another branch.

In those days SVN wasn't so flexibel with branches as we wanted to (or we didn't understand it enough), so our workflow was much more rigid.

Re:Some bad Git situations and how I got myself out of them by screwt on Friday September 09, 2016 @05:18AM (#12460602)
I'll second brusch64 here.

I used SVN for 7 or 8 years and then Git for the past 3, with about a year of overlap (on different repos).

To me, Git is vastly superior. I tend to use it in quite an "SVN-like" fashion - there's a single main trunk branch that we all share - but in terms of what I can do locally it blows SVN out of the water.

The difference is that Git makes things that are hard or impossible in SVN trivial. So for e.g. I create local branches all the time; I commit a bunch of small changes locally as I experiment with a fix, and then `merge --squash` to leave a clean history for others; merging fixes across different branches is easy and just works.

Re:Some bad Git situations and how I got myself out of them by TickleSteve on Friday September 09, 2016 @05:36AM (#12460684)
Finally someone with a real advantage that a DVCS (not necessarily git) has over SVN.... local branches.

Most people just spout the same sheep-like line "git>svn" without being able to justify it!

Re:Some bad Git situations and how I got myself out of them by tempodox on Friday September 09, 2016 @04:36AM (#12460473)
I concur. I would assume that git is the right tool for Linus's workflow, but whatever that is, it isn't mine. SVN does all I need and it has a friendly API and helpful documentation. In other words, the exact opposite of git.
Re:Some bad Git situations and how I got myself out of them by apk17 on Friday September 09, 2016 @05:14AM (#12460589)
SVN is a glorified backup - which is basically what you're saying.

The SVN UI is just horrid in other dimensions, mainly the "you can't do that at all" one.

Re:Some bad Git situations and how I got myself out of them by TickleSteve on Friday September 09, 2016 @05:37AM (#12460685)
sorry... you come across as a git-sheep.

(getting down-voted for it, but someone has to say it)

Re:Some bad Git situations and how I got myself out of them by apk17 on Friday September 09, 2016 @08:53AM (#12461670)
I'm prepared to give you a lot of examples (which other people might value differently). From the unfortunate consequences of the 'branches are files (and therefore tags are easily mutable by default and surprisingly hard to pin down)' to usual "I just committed, why does 'svn log' not show that?", to git bisect, to git clean and the stubbornness with which svn refuses to even consider implementing that.
Re:Some bad Git situations and how I got myself out of them by pjc50 on Friday September 09, 2016 @10:32AM (#12462564)
TortoiseSVN provides the "clean" functionality if you want it.
Re:Some bad Git situations and how I got myself out of them by TickleSteve on Friday September 09, 2016 @09:32AM (#12461982)
that sounds like process-issues... not SVN issues.

tags should not be committed to... end-of-story.

as for 'svn-log not showing commits'... I've never heard of that one in the last decade of using it... I'm genuinely interested in how that came about.

Re:Some bad Git situations and how I got myself out of them by ewjordan on Friday September 09, 2016 @11:58AM (#12463395)
Yep, Mercurial's the one. It's a shame that it lost the war, they actually seemed to care about providing a good experience to their users. There are, of course, a few technical differences between it and git, but I personally never felt like they were troublesome enough to make up for the vast difference in usability.
Re:Some bad Git situations and how I got myself out of them by marcinkuzminski on Friday September 09, 2016 @12:38PM (#12463813)
I think Mercurial hasn't lost it yet. I speak as a creator of Mercurial Source Code management system (RhodeCode)

We see that a lot of companies(our clients/users) adopting Mercurial, you just don't hear about it. Often those are companies with employees that don't tweet or post to HN ;)

RhodeCode is used also in around 60 universities, and we learned that in a lot of them they teach Mercurial as well as Git.

For a large company it's actually much cheaper to adapt Mercurial as they new DVCS because of learning curve.

I hope companies like Facebook and Mozilla will make soon Mercurial very very fast. There's constant work on it coming from those companies to improve it.

Re:Some bad Git situations and how I got myself out of them by RJIb8RBYxzAMX9u on Saturday September 10, 2016 @03:16AM (#12468098)
I don't think hg is going anywhere, if CVS is still alive and kicking in 2016, and especially since Facebook's using it. However, IMO hg lost when even python switched to git.
Re:Some bad Git situations and how I got myself out of them by brusch64 on Friday September 09, 2016 @04:25AM (#12460431)
What are the superior foes in your opinion ?

I don't know any of the other distributed version control systems. The only other version control system I have much (too much) experience with is Subversion and it can't hold a candle against Git.

In my opinion Git is the C language of version control systems. If you are careless it's not the tool for you. Otherwise you have a really great tool with lots of power.

Re:Some bad Git situations and how I got myself out of them by ubernostrum on Friday September 09, 2016 @05:32AM (#12460657)
I don't know any of the other distributed version control systems.

In an ideal world -- one where network effects of GitHub hadn't crushed all competition -- I'd get to choose Mercurial as my daily version-control system. It has similarities to git, in that both are largely user interfaces to a DAG, but its guiding philosophy and approach to the interface it exposes are far better in my opinion.

In my opinion Git is the C language of version control systems. If you are careless it's not the tool for you.

You probably don't want to make that assertion; we now have close to half a century of evidence that no human currently living can use C safely, and I don't think you'd want that to carry over to git. And it's not a matter of "careless" or not -- extremely intelligent, extremely-well-trained, extremely-careful people still write unsafe C.

Re:Some bad Git situations and how I got myself out of them by brusch64 on Friday September 09, 2016 @05:59AM (#12460758)
>we now have close to half a century of evidence that no human currently living can use C safely How many operating systems are written in C ? How many of the more mainstream operating systems are written in other languages ?

You're right that C is the wrong tool for a lot of applications. But if you need total control and speed and power it still works for many projects.

Re:Some bad Git situations and how I got myself out of them by pluma on Friday September 09, 2016 @05:58AM (#12460755)
I've heard a lot of people who seem to know their stuff say that Mercurial is superior to Git in almost every way, especially when it comes to integrating with other tooling (i.e. Mercurial seems to have an API whereas automating Git boils down to spawning shell commands). This also seems to be why Facebook switched from Git to Mercurial: they needed to be able to check out individual folders from a branch and Git simply didn't provide any way to do that without first checking out the entire branch.

Be that as it may, it's a common misconception that the more popular tool is always the better tool. There are a lot of factors to a tool's success and the technical ones are generally far less important than most people think.

Re:Some bad Git situations and how I got myself out of them by majewsky on Friday September 09, 2016 @08:36AM (#12461544)
What's so bad about spawning shell commands?
Re:Some bad Git situations and how I got myself out of them by ewjordan on Friday September 09, 2016 @12:12PM (#12463552)
People have already mentioned it, but since I made the original comment, I'll pile on and say that Mercurial was (well, still is, but it's out of fashion now) awesome. It matches Git on most axes and blows it out of the water when it comes to usability and "don't shoot yourself in the foot"-ishness.

Brushing aside some relatively minor differences, Mercurial is very similar to Git, except that it was designed by people that don't have an all-consuming disdain for all of humankind.

Re:Some bad Git situations and how I got myself out of them by TickleSteve on Friday September 09, 2016 @05:31AM (#12460653)
Can you justify git>subversion or are you just following the sheep?

Not saying I disagree... but subversion is still king in the corporate-engineering companies and it tends to work well in those types of setups.

Just beware of having unjustified-opinions. SVN may not be trendy... but neither will git in a few years time.

BTW: Mercurial still beats them all.

Re:Some bad Git situations and how I got myself out of them by Grue3 on Friday September 09, 2016 @07:17AM (#12461084)
>subversion is still king in the corporate-engineering companies and it tends to work well in those types of setups.

For some values of "work". We're using SVN at my new job, with a single trunk branch. Not having the ability to commit locally, and mess around with local branches is a pain in the ass. I found a solution though. I cloned SVN repo using git-svn and now I can make local commits like a pro, and use my beloved magit (Emacs git interface).

Re:Some bad Git situations and how I got myself out of them by apk17 on Friday September 09, 2016 @08:59AM (#12461709)
Yes, git-svn is probably the reason why the mutiny didn't happen yet in some departments. You can identify their users by having several SVN commits in as many seconds.

(I used git in an cvs-to-svn migration, and stayed since.)

Re:Some bad Git situations and how I got myself out of them by brusch64 on Monday September 12, 2016 @03:53AM (#12477905)
for me the biggest advantage is working in my own repository and then pushing the changes upstream. I can develop features independent of other features. If there is a bug I can fix it, merge it into the productive branch and carry on working on other features.

I know that many people don't like it, but I can fix up commits in my local repository and push the change upstream in one.

With SVN I wasn't able to do this, so it was a big pain if you had to fix a bug if you were in the middle of a big feature, or if you had an experimental feature you wanted to clean up and release a month later.

Re:Some bad Git situations and how I got myself out of them by rootlocus on Friday September 09, 2016 @04:04AM (#12460356)

  > just happened to win the PR battle against its superior foes, because...Idunno, Linux, I guess?
I would assume GitHub is to blame for that
Re:Some bad Git situations and how I got myself out of them by infodroid on Friday September 09, 2016 @01:10PM (#12464142)
> terrible software

The Git DAG and its content-addressable file system are an elegant solution to the problem of distributed version control. The implementation is clean and dead-simple, yet immensely powerful. This is the basis of good engineering.

> an even worse UX

Git was designed to expose its underlying implementation and not to isolate the user from it. Unlike other systems, its subcommands give the user the ability to manipulate the underlying data structure directly.

That doesn't mean it has a bad UX. Just that it has the UX of a power tool.

I also think that Git played a big role in the growth and popularity of command-line tools over the past decade. And that its interface inspired the subcommand pattern that is now commonplace in docker, vagrant, and others.

Re:Some bad Git situations and how I got myself out of them by dboreham on Friday September 09, 2016 @08:40AM (#12461568)
First time I've wanted to upvote twice!

I think besides a PR battle (there's PR people for RCS'es??) I think Git won out because "the server was free". Competitors at the time needed a big (if there were large numbers of committers) server that someone had to pay for. By that I mean the hardware to host the server -- Git needs either none, or a very lightweight machine for a server.

Re:Some bad Git situations and how I got myself out of them by tempodox on Friday September 09, 2016 @04:33AM (#12460462)
> ... that just happened to win the PR battle ...

Chalk that up to the power of fashion. Otherwise, people would use an SCM that doesn't destroy their work in the blink of an eye and actually has an API that deserves the name.

Re:Some bad Git situations and how I got myself out of them by EdiX on Friday September 09, 2016 @07:46AM (#12461256)
The only way to lose work with git is either to (a) not commit it or (b) run a garbage collection.
Re:Some bad Git situations and how I got myself out of them by apk17 on Friday September 09, 2016 @09:02AM (#12461728)
...and having commits that are not referenced by any branch.

And (c) lose the entire subtree the repo is in.

Re:Some bad Git situations and how I got myself out of them by coldtea on Friday September 09, 2016 @05:29AM (#12460645)
>I don't know if this post was intended as humour or a way to vent out some frustration but in my experience, this path of treating git as "spell X solves problem Y" will always break dow

I disagree. "spell X solves problem Y" is an excellent way to both get started with fixing your Y fast AND for learning a system deeper.

I think we better learn by example (such as that) and in practical use over time, as opposed to getting some abstract knowledge of the whole system first, or (god forbid) reading the manual, which noone does.

Re:Some bad Git situations and how I got myself out of them by Grangar on Friday September 09, 2016 @05:44AM (#12460707)
I disagree. Using Git (or any terminal interaction for that matter) is much like speaking a language. As a metaphor: you might be able to order two beers in German (zwei Bier bitte), but the moment the waitress asks you what brand you want it comes down to guessing.

Some coworkers (across all experience levels) use Git this way. It's frustrating how slowly they learn and conversely, how inefficiently they work.

Re:Some bad Git situations and how I got myself out of them by coldtea on Friday September 09, 2016 @06:19AM (#12460825)
>Using Git (or any terminal interaction for that matter) is much like speaking a language

Which again, we learn best by absorbing bits and pieces piecemeal over time -- that's how toddlers learn their native language, by immersion. Not by getting some "understanding of fundamentals" course first.

Re:Some bad Git situations and how I got myself out of them by pauljaworski on Friday September 09, 2016 @03:50AM (#12460312)
Knowing Git "inside out" is great, but you can't expect to know/remember every command for every situation from day one or even day one thousand. A list of ways to solve Git problems serves as a refresher and even a tool for gaining more insight into how it works as a whole.
Re:Some bad Git situations and how I got myself out of them by rtpg on Friday September 09, 2016 @02:25AM (#12460009)
I think there's a bit of that in git in particular.

The irony is that if you think of git in terms of deltas, with branches just being tags to commits, and "git commit" actually being "git commit + move branch", then a lot of stuff is easier to reason about.

Like, if you get the notion of working tree, staging area, commits, and branches on a deep-ish level, things get easier. Things can still be hard, but there's a lot less "does running this cause everything to disappear???"

I think it would be possible to make this awesome page even more awesome with a little "annotated version" that gives the details of what you're actually doing.

Re:Some bad Git situations and how I got myself out of them by dfsegoat on Friday September 09, 2016 @03:23AM (#12460209)
> and "git commit" actually being "git commit + move branch"

Can you elaborate on that a little more? I liked where it was going -- because being able to explain how git works to someone coming from SVN has been an ongoing problem for me.

Re:Some bad Git situations and how I got myself out of them by _ikke_ on Friday September 09, 2016 @03:56AM (#12460336)
In git, branches are pointers to commits (branches are a specific kind of refs or references). When you commit, git creates a new commit object, links it to the last commit on that branch, and then points that branch to the new commit.

This way, you get a chain of commits, each pointing to the previous commit, and and branch references pointing to the last commit of each branch.

Re:Some bad Git situations and how I got myself out of them by chaosemer on Friday September 09, 2016 @04:07AM (#12460371)
Simplifying things a bit, git is what you did before you learned about using version control. That's right, it's just the old copy/paste the entire project folder for each revision and give it a name like "Project v1", "Project v2", etc. Branches and tags are then just symlinks to a specific folder.

In this world, when you commit, you're doing two things: 1. Creating a new top level folder, e.g. "Project v42". 2. Updating the branch symlink you are on to point to that new folder.

I'm actually not simplifying things that much here, the main git addition is that each folder (revision) also has a list of previous folders (revisions) and that the folders (revisions) are not named sequentially, they are named based on a hash of their contents.

Re:Some bad Git situations and how I got myself out of them by prance on Friday September 09, 2016 @03:36AM (#12460261)
I agree that it's worth it learning git properly, but sometimes you're thrown into the deep end and don't have the time to get up to speed the "right way". I think git is complicated enough to warrant some simplified descriptions for the most-required tasks.
Re:Some bad Git situations and how I got myself out of them by dozzie on Friday September 09, 2016 @05:45AM (#12460710)
> sometimes you're thrown into the deep end and don't have the time to get up to speed the "right way".

So you don't have three hours to read the fsckin' manual that describes how git repository is organized? O_o

Re:Some bad Git situations and how I got myself out of them by prance on Friday September 09, 2016 @07:12AM (#12461065)
At this point I think we need to define what it means to "learn git properly". The assumption in this discussion is that it is more than learn a few concrete commands for specific tasks in a few minutes. You say 3 hours is sufficient, but is it?

For example, something as simple as "Changing the Last Commit" (as in "git commit --amend") is found in chapter 7.6 in the git book which is given as main documentation on git-scm.org. The first 6 chapter mainly deal with introducing the model, architecture and high level workflows. Even if you skip the chapter on github, that's still 5 chapters on mostly theory to read before you get to some often-used tool commands. I would argue that is more than 3 hours for most people if you don't just skim it but try to also understand it.

Apart from that, to answer the question: indeed, often I don't have 3 hours for something to be considered "nice to know" as opposed to "absolutely necessary". And if the manual is a "fsckin'" one, I'm unlikely to read it at all.

Re:Some bad Git situations and how I got myself out of them by vacri on Friday September 09, 2016 @02:30AM (#12460026)
Git has enough bells and whistles that a cheat sheet is fine, in my opinion. It's only a problem if you don't understand the commands (the same problem as blind copy-pasting code from the web)
Re:Some bad Git situations and how I got myself out of them by falsedan on Friday September 09, 2016 @01:45PM (#12464448)
> this path of treating git as "spell X solves problem Y" will always break down

I agree completely! Anytime you give a list of 'run this command', I think you've actually written a CLI tool in the wrong language (English instead of a programming language).

At work, we want to increase dev's confidence with git in the next few months. We're making sure to separate out 'Technical' knowledge (what do steps do I perform to recover a deleted branch) from 'Conceptual' knowledge (why would it be a good/bad idea to delete a branch, how branches are intended to be used, understanding what git thinks a branch is, etc.). The former go into git aliases or CLI swiss army knife tool, the latter into training videos and workshops.

Re:Some bad Git situations and how I got myself out of them by swang on Friday September 09, 2016 @02:32AM (#12460037)
it was really hard for me to understand vim until a website explained it as being a set of grammars you can learn.

i agree, if you really want to be more productive (and without having to go find some git expert on your team) knowing how each operation works and why its doing what its doing is really beneficial.

despite that, its sometimes frustrating due to inconsistencies in the git "grammar" that i sometimes don't understand, like why if you want to apply only one file from git stash you have to use `git checkout` rather than `git stash apply [<stash>] -- <file>`. it makes "sense" but is unintuitive when i'm thinking about using stashed commits.

Re:Some bad Git situations and how I got myself out of them by InclinedPlane on Friday September 09, 2016 @02:34AM (#12460044)
The absolutely easiest way to learn vim is to just schedule a reminder every ... month? week? to run "vimtutor". Then do that for a few minutes until you get frustrated or want to do something else. It's shocking how fast you'll learn.
Re:Some bad Git situations and how I got myself out of them by wonder_er on Friday September 09, 2016 @10:27AM (#12462514)
Thank you for this! I didn't know `vimtutor` existed, and just finished the first full lesson. I've got to work now, but I'll be back.

Thank you!

Re:Some bad Git situations and how I got myself out of them by pluma on Friday September 09, 2016 @05:49AM (#12460730)
I think the reason you're disagreeing is that you're not looking at this from a beginner's point of view.

Generally there are (roughly) three approaches depending on where you are in your journey from beginner to expert:

As a beginner, you need specific, detailed, step-by-step instructions: First run X, then run Y, finally run Z, if something goes wrong along the way, follow these other steps, if that doesn't work, ask someone for help.

Once you've moved beyond being a beginner, you understand how the different steps are connected, so you already know the intermediate steps and just need to be told the task at hand: do an X (e.g. "move these commits onto the other branch").

An expert fully understands all the inner workings and just needs to be told the big picture: this is what I have, that is what I want, make it happen.

If you try to instruct experts like beginners, they will be frustrated because it seems so tedious and you're not giving them the information they want: what you're trying to do. If you try to instruct beginners like experts, they will be horribly confused because they don't know how to make any of it happen without you laying out each individual step they need to follow.

A case can be made that a beginner should learn each individual operation by heart before moving on to the next one (like kata in martial arts) but this style of learning assumes you're willing to spend a lifetime perfecting a single art. It's unlikely git will stick around that long and for most of its users git is just a tiny (though important) aspect of their work.

Re:Some bad Git situations and how I got myself out of them by majewsky on Friday September 09, 2016 @08:53AM (#12461669)
"A lifetime" is massively exaggerated. I would argue that I know the majority of intricacies of every git command, and I've spent much less than a lifetime on this (about 2 years in reality, alongside other things, of course).

> As a beginner, you need specific, detailed, step-by-step instructions: First run X, then run Y, finally run Z, if something goes wrong along the way, follow these other steps, if that doesn't work, ask someone for help.

That's one way to do it, but it's not preferable. I would rather sit the beginner down for at least an hour and go through the basic concepts with them.

I've taught Git to a few people (mostly fellow students or colleagues) and I found that they have a much easier time when they are introduced early on to the basic concepts of Git (the commit graph, and branches/tags as pointers into the graph), they have a much easier time grasping relevant tasks like merge and rebase.

For specific questions (mostly in these "I screw up" moments), a whiteboard is also really helpful to explain them how the two or three magic commands that I tell them are actually fixing things up.