r/programming • • Jun 19 '14

Reinventing GIT interface

http://tonsky.me/blog/reinventing-git-interface/
221 Upvotes

325 comments sorted by

View all comments

Show parent comments

22

u/rwilcox Jun 19 '14

Any halfway competent developer should be able to master git in a couple of weeks

I disagree. I've been using Git every day for 6 years now and I've found Git's learning curve to be like a rollercoaster loop-de-loop: you're doing OK, then suddenly you need to do something that makes you go WTF so much you feel like you know less than you did 6 months ago.

git add, git commit, git push, basic branch workflow, sure. Mastering Git? I'd say years.

Quick how do you find the name of the branches the current commit is on? Push the current branch to the server but name it something different? Tell me about git push --force. What does git fetch do? What's in your global core.excludesfile file?

(Seriously, the number of developers that don't even know about Git's global ignore options is staggering. (I should never see .DS_Store files in my Git repo, but what do I see all the fracking time? .DS_Store files... Yes, thanks OS X, but still....))

3

u/[deleted] Jun 19 '14

Do you ever memorize all the functions and their arguments in the standard library of your language?! If you think you have to; you're doing it wrong.

To answer your questions, and this is off the top of my head:

Quick how do you find the name of the branches the current commit is on?

I don't. I always have the name of the branch printed as part of my bash prompt. I think git branch puts a start next to the current branch name.

Push the current branch to the server but name it something different?

git push remote_name local_branch_name:remote_branch_name

Tell me about git push --force.

Push the branch after rebasing. Basically force the push even though it would change the history for the branch.

What does git fetch do?

Download the data from the remote without merging any remote branch to your local branch.

What's in your global core.excludesfile file?

I don't know :)

6

u/Peaker Jun 19 '14

I always have the name of the branch printed as part of my bash prompt

I think he means something more like:

git branch --contains HEAD

git push remote_name local_branch_name:remote_branch_name

It's not really "local_branch_name" but "local_refspec", which confusingly, must be a branch name iff the remote branch name does not currently exist.

Push the branch after rebasing

Not after rebasing -- but whenever it's not a fast-forward in general. i.e: You can push it back a few commits, or after commit --amend, etc.

Download the data from the remote

Importantly, update the remote's tracking branches.

1

u/jayd16 Jun 20 '14

Meh, don't commit to memory anything you can easily look up. I would say you've mastered git once you get to a workflow you like. All the esoteric features are to get you out of a mess you shouldn't have been in anyway.

1

u/rwilcox Jun 20 '14

Well, we actually have the Dryfuss model for skill acquisition, which I forgot about until now.

Git's CLI doesn't help the learning curve and the surprising number of times I find myself using plumbing instead of porcelain commands to accomplish tasks... doesn't help matters.

-5

u/[deleted] Jun 19 '14 edited Jun 19 '14

I don't get what more is beyond "mastering" it ... Once you can successfully deploy/support a project with it you're doing exactly what it was meant for.

Hell if you do something freakishly stupid you can still just hack the packfiles/objects directly ... it's not like the file format isn't documented.

We've shipped several dozen tagged releases of over a half dozen different projects to customers already and even have a few LTS branches floating around. I can't imagine another task I'd be doing with Git [on purpose] that I haven't already encountered.

edit: To answer your questions though: Which branch a commit is on? You don't because that's not how git works. You can always see if they are connected by doing something like git log foo..bar, why would you want to rename a branch but it's git push -u origin new_name, I never use --force ... and I've never used excludesfile

6

u/rwilcox Jun 19 '14

Which branch a commit is on? You don't because that's not how git works.

git branch -a --contains SHA1 (I knew I knew this...)

why would you want to rename a branch

Pushing a branch to a staging server that assumes the current code is on master. (Because stupid).

(git push destination current_branch:destination_branch)

I never use --force

Right, except that one or two times a year when you have to.

Anyway, every team seems to have this one developer whose head and shoulders better than everyone else at Git. I would not assume this is because the other developers suck, but because the more one (or maybe just me) learn about Git the more that thinking about Git as homeomorphic endofunctors mapping submanifolds of a Hilbert space seems like the sane way to view Git. Which may make Git logarithmically complex to learn.. and I say this as someone whose contributed to libgit2.

1

u/[deleted] Jun 19 '14

git branch -a --contains SHA1 (I knew I knew this...)

Cool.

I mean I've never needed to know which branches contain a commit but good to know git has an answer to that.

Right, except that one or two times a year when you have to.

I've never needed to use force. Force implies you fucked up the tree.

0

u/loup-vaillant Jun 21 '14

Git as homeomorphic endofunctors mapping submanifolds of a Hilbert space

Err… does that makes sense? (I don't know those terms —except endofunctor), so I can't say if you were being serious.

4

u/masklinn Jun 19 '14

So by "mastering" it you don't mean mastering at all, but learning a few commands which seem to work by rote?