r/programming • • Feb 06 '15

Git 2.3 has been released

https://github.com/blog/1957-git-2-3-has-been-released
622 Upvotes

307 comments sorted by

View all comments

12

u/cakes Feb 06 '15

Is there any good resource out there for learning to use git? I've tried about 4 times, and always say "fuck it" and go back to using subversion.

37

u/[deleted] Feb 06 '15 edited Feb 06 '15

The problem is that you're giving up. You have to have the mindset that you will do something you set out to accomplish, and that giving up is not an option. Why give up? It's definitely not because it's not possible. Because you find it hard? So what? Just learn a little a time.

I recommend the book "Pro Git". The first 4-5 chapters are enough to use git in real world (e.g., workplace) projects.

Also, learn about "git-flow", and use it as a crutch to make git easier at first. It's a workflow you can read about online, and there are a set of scripts you can install that implement it. After a while you will start to use git without git-flow and abandon the git flow scripts, but probably keep the workflow concepts. This is what I did.

EDIT: Here is the description of git-flow that I initially found useful. I haven't read it since, so I'm not sure what my take on it would be at this point. But the graphics are better than what you get on the Atlassian site, which is the first google result when you google "git-flow".

2

u/cakes Feb 06 '15

Definitely agree there, I guess I give up on it because it's not a necessity for what I do (I already have something that works for my purposes). Grabbing pro git for kindle now and I'll check out git-flow too. Appreciate the suggestions! (everyone elses suggestions too)

3

u/ForeverAlot Feb 06 '15

Note that git-flow has some administrative overhead. I vastly prefer the GitHub Flow variant for most personal projects. My colleagues are less disciplined with version control and frequently push half commits, so for work I fall back to a lightweight variant of git-flow that doesn't use release branches.

→ More replies (1)
→ More replies (7)

6

u/seagu Feb 06 '15

Do you have a solid CS background? The article git for computer scientists made it all finally click for me. The key I was missing is that a git repo -- or even the collection of instances of the same git repo on multiple people's machines -- is just a directed acyclic graph. And git commands manipulate that graph.

Once I understood that, I instantly knew how to do fairly fancy things such as merging previously separate repositories.

18

u/gammadistribution Feb 06 '15 edited Feb 06 '15

Because there's not much to learn honestly.

I find it easier than subversion. At least, the workflow easier anyway. It's pretty simple to make a branch do your thing then merge the branch with the trunk. It only takes like 4 commands to do all of that.

EDIT: Ok, you said resource not reason. Sorry.

7

u/the_omega99 Feb 06 '15

I think most of the difficulty is trying to do tasks that are "optional" (ie, not needed for ideal usage of the program, but you will need at some time). For example, how do I stop git from making my scripts non-executable? Fortunately, there's absolutely no reason to remember (learn) these kinds of things. Just google when you need them. I still haven't memorized the syntax to restore a single file from an older commit, but I know where to find the command when I need it.

Pretty much all you need to memorize is:

  1. Cloning (getting a new repo from the internet)

  2. Checkout (switching branches)

  3. Pulling (getting changes from remote repo)

  4. Pushing (adding your changes to the remote repo)

  5. Diffing (viewing changes you've made, or changes between commits, branches, etc)

  6. Checking the status (to see which files are changed, etc)

  7. Adding (staging files to commit)

  8. Commiting (creating a revision with staged files)

  9. Branching (creating a new branch)

My advice when going from SVN to git is to FORGET EVERYTHING ABOUT SVN! If you try and apply existing knowledge about SVN to git, it will bite you in the ass. So don't assume that because you're competent with SVN that you know anything about git. This will stop misconceptions from hindering your learning.

As for a resource, the official tutorial is great. They also have a well written book for when you need more details.

3

u/sirin3 Feb 06 '15

My advice when going from SVN to git is to FORGET EVERYTHING ABOUT SVN!

Guess that is why I never managed to understand git

But I am too lazy to learn it and just use Mercurial

2

u/noratat Feb 07 '15

Mercurial's a perfectly good choice, and is very similar to git and has most of the same advantages git does over older tools like svn.

→ More replies (1)
→ More replies (1)
→ More replies (2)
→ More replies (12)

11

u/[deleted] Feb 06 '15

Just try mercurial instead. Much friendlier to svn brains, with all the decentralisation you could want.

6

u/cakes Feb 06 '15

I've heard this suggestion before, but my motivation to learn git is so I can use and contribute to projects on github, and potentially use it for my own projects if it offers me any benefits (which people are telling me it does).

8

u/ForeverAlot Feb 06 '15

Both Mercurial and Git have adequate bridges for each other, and are conceptually so similar that it really makes little difference in the end. But I started with Mercurial, and now firmly believe both that Git's model is saner and that Mercurial's UI mostly isn't any better than Git's.

I also believe DVCS to be strictly superior to CVCS for most things but there are issues inherent to DVCS that lead to problem areas. Undiffable files are a prime example, so, for instance, artists, would not likely benefit from DVCS at all. But for source control, DVCS do everything Subversion does, only better and faster.

3

u/blktiger Feb 06 '15

I started with Mercurial before learning Git and I felt like Mercurial was an easy transition from SVN while still giving me a good grasp on the concepts needed to understand Git. http://hginit.com/ is a really good place to understand Mercurial. Maybe even just reading through that and then learning Git would be enough to get you there?

3

u/McGlockenshire Feb 06 '15

There are two big things to adjust to when switching from svn to git.

The first is the decentralized model. You should learn Mercurial because the command set it uses is way way more sane when coming from svn. Learning Mercurial will help you get comfortable with the distributed workflow with a relatively low barrier to entry from svn.

The second is git's command set. It's schizophrenic and a good number of the commands have names that are unexpected given what they do and what many other tools call the same operation.

→ More replies (2)

3

u/HomemadeBananas Feb 06 '15

You should definitely still learn how to use git regardless, considering that's what everybody else uses.

3

u/[deleted] Feb 06 '15

Actually, I pretty much only work on my own projects, so I get to live in this little bubble where my tools actually are made to work for me.

3

u/HomemadeBananas Feb 06 '15

I don't think you could avoid ever running into a time where you need to use git to work on a project, unless you literally never work with other people or work on an existing project.

→ More replies (2)

2

u/XPEHBAM Feb 06 '15

Atlassian has pretty good Git resources. You could start using Sourcetree and do everything in the GUI to help you learn. The best resource is to just jump in and start using it and check stackoverflow when you hit a roadbump.

2

u/[deleted] Feb 06 '15

Why? They aren't that different. I started with the github tutorial. I also learned svn first, now I could never go back. You can even use an svn repo from git.

2

u/Eurynom0s Feb 07 '15 edited Feb 07 '15

I think the issue is if you're trying to do tons of fancy things in git or just need the basic.

I've found the four most basic commands you need are git status, git add, git commit, and git push, and the flags I commonly use with them...for the rest, I Google as needed.

Obviously you'll need a few more than those as your basic toolkit (git clone, git checkout) but you can get pretty far with those depending on your use case.

I like this tutorial when I need to read up on a functionality instead of just quickly Googling for a command or a flag.

5

u/[deleted] Feb 06 '15

People still use subversion??

0

u/[deleted] Feb 06 '15

[deleted]

→ More replies (3)

4

u/mfender7 Feb 06 '15

A lot of companies also use it. Or some hybrid of git/svn.

→ More replies (26)
→ More replies (14)