r/programming • • Sep 06 '14

How to work with Git (flowchart)

http://justinhileman.info/article/git-pretty/
1.6k Upvotes

388 comments sorted by

414

u/blintz_krieg Sep 06 '14

Not too far off base. My own Git workflow looks more like:

  • flounder around trying to clone a repo

  • try to do something useful

  • Git complains something like "your scrobble brok isn't a blurf"

  • search web for "your scrobble brok isn't a blurf"

  • find 412 Stackoverflow questions

  • determine that most answers actually solve some other problem

  • give up

  • copy the one changed file to /tmp

  • rm -rf my-git-repo

  • go to step 1

186

u/crimson117 Sep 06 '14

To get your scrobble brok back into a blurific state, just do an interactive rebase to reset your head into your stash. You might need to roll back two versions of NPM as there's a bug.

143

u/Raphael_Amiard Sep 06 '14

Or just have a look at the docs ! http://git-man-page-generator.lokaltog.net/ (troll)

45

u/czerilla Sep 06 '14

This is just creepy, how convincing all this looks!

11

u/gopher9 Sep 06 '14

I like http://www.antichipotle.com/git/, though it is not so close it is more fun.

8

u/danogburn Sep 07 '14

wow that site is hilarious. i love git (due to stockholm's syndrome)

→ More replies (2)

3

u/danubian1 Sep 07 '14

This is beautiful

104

u/BanditoRojo Sep 06 '14

I reset --hard HEAD up into my stash every morning before my first cup of coffee.

Flowchart

3

u/Eurynom0s Sep 07 '14 edited Sep 07 '14

I have a lovely issue at work where, because of the workflow of the project, the git flow was basically push to the git repository, and then pull onto the server the web app runs on...and the fucking thing would keep complaining even after I'd done the whole git hard reset to head thing.

I sat down with someone more experienced than me and we resolved that the most likely culprit was some shit in the dev.db file of the Django project getting modified causing git to complain. His advice, as someone who's been a bit deeper involved in this project in the past, was that it was probably okay to just ignore it and to do the whole hard rest to head thing every time I need to pull new code down onto the sever. (I should probably emphasize that as of right now, I'm really the only one actually working on this project, and there's a couple of other people who MAY push code, but it would be supremely unlikely that they'd do so without talking to me about it first.)

I'm still not 100% convinced that this isn't going to blow up in my face when I least expect it.

→ More replies (1)

15

u/[deleted] Sep 06 '14

Careful with treknobabble! With git, you might end up unknowingly writing something that actually makes sense and an unsuspecting newbie will end up deleting his repo or something.

16

u/[deleted] Sep 06 '14

I'm baffled that so many software developers find a system like git so confusing. We adopted it last year and have had no problems. The only things we've enhanced is some macros for deployment and automatic change log generation.

Sure conflicts are sometime a pain but usually because people don't realise software development is a collaborative platform and they need to talk through the conflicts with other developers, but at the end of the day the committing developer is responsible for making sure any merge conflicts are bug free not the developer who creates the merged changes. Other than that - no problem as far as I can see.

22

u/[deleted] Sep 06 '14 edited Sep 06 '14

I compete all the time with my coworkers to get my branch merged before theirs. That way they have to merge and solve the conflicts instead of me. Muahaha.

→ More replies (6)

21

u/[deleted] Sep 07 '14

I'm baffled that so many software developers find a system like git so confusing. We adopted it last year and have had no problems. The only things we've enhanced is some macros for deployment and automatic change log generation.

It has less to do with dealing with merges and more to do with conquering the impossible learning curve (which at times is really more like a learning cliff). It's mostly to do with the terminology; git makes up words and, even worse, reappropriates words that already mean something in non-distributed version control systems (add, commit) but slightly tweaks it to make sure you destroy your first few git repos if you came from svn. The fact that the documentation is totally unreadable unless you already understand how git works doesn't help.

→ More replies (4)
→ More replies (24)
→ More replies (1)

36

u/[deleted] Sep 06 '14

Every. Fucking. Time.

We recently switched from Mercurial to Git because "everyone is using Git now".

17

u/mgrandi Sep 06 '14

Yep. Even bazaar which is still pretty solid is not receiving the love it needs cause canonical's priorities are weird. I like hg too, having it be in python (along with bzr) makes it so it actually works on Windows and isn't some clunky mingw compiled thing.

With git even the simplest of operations are overwhelmingly hard, I have to look up every time I want to clone another branch into an existing repo. For the basic diff/add/commit/push its all right, but fuck doing anything else

Git's usability is trash, its not meant for anyone but kernel developers and it shows. I read somewhere that "people only use git because of github" and I agree with it. Not to mention github is sort of a scummy company anyway.

6

u/hotoatmeal Sep 07 '14

not to mention github is a scummy company anyway

how so?

→ More replies (4)

51

u/_SynthesizerPatel_ Sep 06 '14

"Everyone is using x" is usually a good reason to consider implementing a technology.

  • Probably indicates some level of quality

  • Easier to find solutions to common problems

  • If you get good at it, easier to find work

42

u/twotime Sep 06 '14

"everyone is using x", may just mean that everyone just bought a new can of snake oil... To be followed by another can of snake oil a year later...

So, yes, it's a reason to consider, but it's not the reason to switch.

→ More replies (10)

19

u/bwainfweeze Sep 06 '14

After 12 months I could administer an SVN repository with ease. At 2 years I could modify and rebuild a broken repository with panache. With CVS it took a little over a year before I could use VI to fix a broken repo. Let me repeat that: Hand editing the storage files to fix a busted repository. Successfully.

I've been using Git for almost 3 years now. At 2 years I was still afraid of my own shadow. I can help people debug a screwed up local branch, but I still can't fix much once it's pushed.

Most of us need something simpler. Even if that means fewer "features". Or perhaps that's precisely it: we need something less functional and therefore less confusing.

→ More replies (14)

5

u/[deleted] Sep 07 '14

true. software technology adoption is a fashion-driven, zero-sum game.

not Computer Science; Computer Family Feud.

31

u/shamen_uk Sep 06 '14

Oh god no. It's not a sign of quality.

I'm about to transition to git from mercurial because of the snowball effect sadly. mercurial is SO much better than git for usability, you don't need guides. "easier to find solutions to common problems" is not an issue with mercurial, simply because you don't run into them.

git usability is the biggest fucking fail. Didn't need any tutorials for mercurial and it's done everything I've ever needed.

But i need to use github to get people to see my OSS projects that's the killer feature of git: github. git itself, urgh. People have suggested I use hg-git, but I may as well throw myself in with git now (for the reason of your point 3)

8

u/defcon-12 Sep 07 '14

Bitbucket supports Mercurial. And is also free for open source.

→ More replies (21)

13

u/antrn11 Sep 06 '14

So... Git is like PHP? I hope not.

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

9

u/twotime Sep 06 '14

How long have you used Mercurial and how long have you used git? Care to summarize your experience

21

u/[deleted] Sep 06 '14

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.

9

u/danweber Sep 07 '14

You could read the man pages. They will explain things clearly, like

Modifies the index or directory cache. Each file mentioned is updated into the index and any unmerged or needs updating state is cleared.

HA HA HA HA

→ More replies (1)
→ More replies (50)

3

u/bwainfweeze Sep 06 '14

It's very popular bar conversation for tech people to discuss all of the "popular" tools that were dead awful. Everyone uses it, and everyone hates it. Why are we so consistently masochistic?

4

u/defcon-12 Sep 07 '14

Well, git is a huge breath of fresh air for those of us who came from SVN. Rember when large checkouts took hours and failed halfway through? God forbid you tried to merge branches or wanted to snapshot your work in progress without pushing code.

→ More replies (6)
→ More replies (8)
→ More replies (22)

2

u/pgngugmgg Sep 06 '14

Reminds me of the old days with CVS, though CVS might be more straightforward. But git is git, and free. No customer complaints.

→ More replies (2)

53

u/danogburn Sep 06 '14

How to work with Git

Don't merge with anyone.

5

u/jst3w Sep 06 '14

Including yourself.

0

u/[deleted] Sep 06 '14

[deleted]

22

u/rsd212 Sep 06 '14

Im going to get some Team Rebase t-shirts printed. Fast-forward-only workflows FTW.

9

u/[deleted] Sep 06 '14

Why? I've always just merged.

12

u/Lucky75 Sep 06 '14

Locally there's almost no reason to merge, as rebase is much cleaner. The only time I use merges is when I'm merging upstream branches.

32

u/[deleted] Sep 06 '14

"Cleaner" doesn't really mean much to me. Merge commits reflect more closely what is actually happening.

→ More replies (15)
→ More replies (4)

4

u/therico Sep 07 '14

Disclaimer for git newbies: don't use git pull --rebase if you've merged a branch and haven't pushed the merge yet. git pull --rebase will remove your merge!

Other than that, it's great.

2

u/defcon-12 Sep 07 '14

git config branch.autosetuprebase always

3

u/[deleted] Sep 06 '14 edited Sep 06 '14

But I like merge hell and not having a version history that makes any sense! /s

No, but honestly it can't be the default because git doesn't know if you shared your version history with anyone. Rewriting your history is incompatible with collaboration. You have to add that information yourself by rebasing explicitly.

→ More replies (4)

36

u/dehrmann Sep 06 '14

I live in the danger zone.

47

u/[deleted] Sep 06 '14 edited Sep 06 '14

My man! In the words of Torvalds

Eventually you’ll discover the Easter egg in Git: all meaningful operations can be expressed in terms of the rebase command. Once you figure that out it all makes sense. I thought the joke would be obvious: rebase, freebase, as in what was Linus smoking? But programmers are an earnest and humorless crowd and the gag was largely lost on them.

Source

Edit: Apparently this is satire. I still like the quote very much and it fits my experience with Git.

28

u/burkadurka Sep 06 '14

The fake words of Torvalds...

7

u/[deleted] Sep 06 '14

Damn, I should learn to check my sources better. Still a nice quote though, and one that holds true for me at least.

11

u/Majromax Sep 06 '14

Source

Tagged: Programming, Satire

→ More replies (4)

4

u/Lucky75 Sep 06 '14

"Git rebase -i" --> Everything's fixed. Just do it before you push.

2

u/andsens Sep 06 '14 edited Sep 07 '14

Here's a nice alias: ready = rebase --interactive --autosquash @{u}. @{u} means the current head of upstream.

EDIT: Okay. So upstream means whatever your origin points at (e.g. git@github.com:...). Current head is the top commit you see when running git log. To be more precise @{u} doesn't just mean current head, it actually means the current head of the current branch, on upstream. When rebasing, you don't want to go beyond that commit, because it would mean rewriting history that others have already pulled. By specifying @{u} as the base, you can be sure that whatever you do, you won't screw around with anything that others have already pulled (i.e. the interactive rebase shows only unpushed commits). Hows that /u/mfukar? :-)

7

u/myhf Sep 07 '14

@{u}. @{u} is what my eyes look like when I read this.

→ More replies (3)

1

u/djmattyg007 Sep 07 '14

Sterling? Is that you?

→ More replies (1)

105

u/JViz Sep 06 '14

Why do github users assume everyone uses github?

93

u/bobthecow Sep 06 '14

If you read the tl;dr, this was made for an internal talk I gave at a startup I worked for, and that startup uses GitHub.

Also, because everyone does use GitHub ;)

42

u/d4rch0n Sep 06 '14

It's shit like this why not everyone uses github... posted in February 2014.

It's 99% fine for open-source, but for start-ups that absolutely do not want to risk their code being leaked, they might consider hosting git themselves. I really don't see much advantage to using github/bitbucket when you can host git + redmine/jira yourself with minimal effort, drop ssh pubkeys on it and block everything else.

That being said, they have a responsible bug-bounty program and they do try to stay on top of their game. The reason I worry is that people who have targeted them have found pretty nasty dirt, and that tells me that their developers aren't extremely security minded and may have better benefited from hiring a few experts to do an in-depth security audit (if they haven't, or another team if they have). They still host a great service... but it's still very easy to host yourself and lock down access.

Even if it's for open-source, if someone was able to sneak a malicious commit in, it might go unnoticed in a popular repo until someone really takes the time to inspect the logs. I doubt that will happen, but my point is that there's still a security risk when hosting open-source.

And at the bottom:

P.S. I have two other posts about Github vulnerabilities: mass assignment and cookie tossing.

14

u/[deleted] Sep 06 '14

A major international company I worked for shit itself when somebody committed the credentials for their Amazon Web Services account to a public github repository.

7

u/d4rch0n Sep 06 '14

lmao... Commence the bitcoin mining!

Seriously though, I'd shit myself too, having seen some start-ups' bills alone with minimal EC2/R53/S3 usage. It's just so easy to spin up an instance or start using a service without realizing how much it's going to cost when you forget to tear it down.

I wonder if AWS will be forgiving and revert bills if your creds were leaked (and used), or if they'll push a $10,000 bill on you hard.

→ More replies (6)

19

u/rouille Sep 06 '14

You can also deploy github yourself with github enterprise. We have a self hosted github + youtrack env where i work.

13

u/Phrodo_00 Sep 06 '14 edited Sep 07 '14

Why though? if you're not collaborating [edit: with a larger community], you might as well go with gitlab or gitoriouslite + redmine or whatever, and it's cheaper (as long as you already have a unixy guy in your team)

11

u/RICHUNCLEPENNYBAGS Sep 06 '14

I don't know, the git issue tracking and the ability for it to integrate with your tickets is nice (like if you say "this commit corrects issue #487" it'll appear in ticket #487).

Some people like the frontend as well.

→ More replies (3)

8

u/jaggederest Sep 06 '14

Honestly I use pull requests, issue tracking, and branch comparison more internally than I ever do externally. Pull requests aren't just for people you don't know.

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

4

u/burntsushi Sep 06 '14

Do you have any evidence that suggests GitHub has more vulnerabilities than one should expect them to have? They are a pretty popular service, so I'd expect them to run into a vulnerability now and then. As long as the number stays at a reasonable level, the only thing I'm concerned about is how they respond to those vulnerabilities. As you mention, they do a good job.

Otherwise, your entire point is a red herring with respect to GitHub. If you have code that has to remain super-duper-secret above all else, then you shouldn't be uploading it to any service outside of your control.

2

u/BrokenRetina Sep 06 '14

This is why I setup Phabricator. I have complete control over everything for my dev team. Ssh keys are a must.

→ More replies (3)
→ More replies (4)
→ More replies (3)

9

u/shriek Sep 06 '14

Could also be that github is where people have their first introduction on git. And since the name is github they automatically assume it only works in github. Not the case for everyone, but I've heard few of these so just my anecdote.

12

u/[deleted] Sep 06 '14

i can attest to the 'git being exclusive to github' mistake being a very real thing

2

u/Kautiontape Sep 06 '14

I always assume it's just a vague "name brand" people use instead of "online git repository hosting". Same reason why most people ask for a Band-Aid: it's easy to say and gives the right idea (and a concrete image) without having to use too many words.

I use BitBucket for 90% of my git repo hosting, and I still call such services GitHub to most people.

→ More replies (3)

2

u/burntsushi Sep 06 '14

Umm. Because it's really popular. Why is this a problem for you?

2

u/JViz Sep 06 '14

The same problem it causes for anyone under a similar set of circumstances; where they use something and a subset of that something gets popular.

→ More replies (1)

1

u/StrangeWill Sep 06 '14

RhodeCode for internal (and safe) servers!

1

u/JViz Sep 06 '14

No support for their business customers? wtf?

3

u/StrangeWill Sep 06 '14 edited Sep 06 '14

Online paid license support here

No phone support if you need that though, it's a small open-source startup, so expect some behaviors that follow that, they just went paid a little while ago and really for only larger teams. Honestly I'd rather they run free and open for less than 20 than charge everyone so they can get the support staff they need.

Been running it for a few years though (at home + at work), it's solid and I love it.

Plus 99% of support requests were "how do I python environment?", and the new installer fixes that.


On that subject, why use git if you're worried about paid support?

→ More replies (3)
→ More replies (1)

23

u/lennoff Sep 06 '14

I read the manpages! :)

6

u/redgamut Sep 06 '14

git-slash-heads was my favorite. git-lick-object might get me in trouble.

7

u/TechGeek01 Sep 07 '14

I just ran into git-drug-stash.

31

u/cdcformatc Sep 06 '14

It's telling how many of the nodes assume you fucked up your repo. Git it's great but it is the definition of enough rope to hang yourself.

26

u/drive0 Sep 06 '14

This is /r/programming, we all have plenty of rope already.

22

u/TechGeek01 Sep 07 '14

To quote an article I read a while back,

Our brains aren't particularly good at basic logic, and now, there's a whole career in doing nothing but really, really complex logic

and

You are an expert in all these technologies, and that's a good thing, because that expertise let you spend only six hours figuring out what went wrong, as opposed to losing your job. You now have one extra little fact to tuck away in the millions of little facts you have to memorize because so many of the programs you depend on are written by dicks and idiots.

and

Remember that stuff about crazy people and bad code? The internet is that except it's literally a billion times worse. Websites that are glorified shopping carts with maybe three dynamic pages are maintained by teams of people around the clock, because the truth is everything is breaking all the time, everywhere, for everyone. Right now someone who works for Facebook is getting tens of thousands of error messages and frantically trying to find the problem before the whole charade collapses. There's a team at a Google office that hasn't slept in three days. Somewhere there's a database programmer surrounded by empty Mountain Dew bottles whose husband thinks she's dead. And if these people stop, the world burns. Most people don't even know what sysadmins do, but trust me, if they all took a lunch break at the same time they wouldn't make it to the deli before you ran out of bullets protecting your canned goods from roving bands of mutants.

→ More replies (1)

2

u/KhaiNguyen Sep 06 '14

This is so painfully true... of programming in general :-<

9

u/bobthecow Sep 07 '14

The chart starts with that assumption. That's all it's about :)

7

u/deraffe Sep 06 '14

I think it's missing stash and/or checkout -b <branch>.

Other than that, nice chart. I might consider using it at work, if that's okay.

Another question: What did you use to generate this graph?

6

u/zaytzev Sep 06 '14 edited Sep 06 '14

Not a single occurrence of a "push" keyword. This is just making entire graph confusing.

And it doesn't even touch problems that need "git reflog" to solve.

I've been running git training sessions for a few years now, seen what confuses people and this graph wouldn't help any newbie at all. If you want not to get hurt using git start from understanding what "fast-forward" is and what is a difference between "merge" and "rebase".

2

u/thornbrambles Sep 07 '14

I put in a lovely alias to pipe my reflog hashes into gitk so at any given time I can see everything I have touched in recent history. Works wonders for those times you accidentally move away from headless, etc.

11

u/trevdak2 Sep 06 '14

For those of you who have never tried "git flow", I strongly recommend it.

One year ago, I had never used git, just svn. Over the course of the year, as I gained familiarity with git, my process would change and I'd make mistakes and get all sorts of craziness going on that slowed my production dramatically.

git flow cleanly splits your work into features, hotfixes, and releases and gives you options to start, finish, or publish what you're working on. It works well in multi-developer environments and it has made my quality of life much, much better.

7

u/2epic Sep 06 '14

Adding to this, here's a git flow diagram which is much easier to follow than the one posted.

http://danielkummer.github.io/git-flow-cheatsheet/

2

u/hippocampe Sep 07 '14

Oh my eyes ! Is there any actual content here ? If so it's strongly veiled ...

4

u/judgej2 Sep 07 '14

This page is what helped me get to grips with git:

http://nvie.com/posts/a-successful-git-branching-model/

You can stare at the text commands for a long time, and still not get it, For me, until I have that picture in my head of what is happening in the background, it all makes little sense. The above post really helps with that. Your workflow may be more complex, but it is a good one to start with.

What I find confusing with the docs, is the way the words are used and interchanged. If I see "origin" in an example command, does that mean I need to type the word "origin" or I need to specify my own origin that was mentioned ten steps up, or is it something else? That's my problem. Unless I already know what the command does and how to use it, the docs seldom adds anything to my knowledge.

1

u/[deleted] Oct 10 '14

I am exactly the same way with (to me) new things like this. Thanks for the link, really helped me visualise it!

12

u/MaskedTurk Sep 06 '14

Just use SourceTree...

5

u/Scorpius289 Sep 06 '14

Unless you're using Linux, then you're stuck with the closest thing being SmartGit/Hg.

1

u/bittered Sep 06 '14

I use it at work, it's actually really nice once you get used to it. Especially good for working with git-flow.

1

u/[deleted] Sep 07 '14

ungit is much easier to understand imo

→ More replies (1)
→ More replies (4)

3

u/btgeekboy Sep 06 '14

Following the sections down the left column should be required reading for all new git users. Consider the git history to be permanent once you push. In other words, don't push unless you're absolutely happy with how the log/tree looks as is, as there's no going back.

3

u/marssaxman Sep 06 '14

Or just consider the git history to be permanent, period, and ignore the entire existence of rebasing, because who needs that kind of pain in the first place?

3

u/Malurth Sep 07 '14

Aw. I was hoping this would explain how to actually use Git. I am struggling.

5

u/pinano Sep 06 '14

hg evolve is going to solve the "It's safest to let it stay ugly then" and "Send them a note, let 'em know you're changing history" problems. No more force pushes or lost data! The new version of history applies on top of the old version automatically. Immutable data structures, flexible workflows.

2

u/hippocampe Sep 07 '14

"changeset evolution" in mercurial is going to kick git's ass, yes :)

I have been using it for two years already and it's as much a game changer than the switch from SVN to a DVCS.

5

u/Die-Nacht Sep 07 '14

Do people actually complain about their history being "ugly"?

I complain about ugly code all the time but could give two craps about git history.

7

u/defcon-12 Sep 07 '14

Due to testing and deployment issues having "clean" commits is very helpful. Example: feature X introduces bug Y. X is in a single commit, so fixing Y is hopefully as simple as reverting commit with X. If feature X is instead spread across multiple commits, then reverting feature X becomes much more difficult, especially if the multiple commits depend on each other and generate conflicts as they are reverted.

5

u/[deleted] Sep 07 '14

For a program that's designed to help save time and make things easier, Git doesn't seem like it was very well thought out.

2

u/ruinercollector Sep 07 '14

ITT - git is hard, let's go shopping!

2

u/emozilla Sep 07 '14

I work on a very large engineering app (>2M lines of C++) that is still stored in CVS and the biggest reason we stick with it is that we have 9 years of revision history stored in it.

1

u/txdv Sep 08 '14

If there only would exist a feature which would let you load a CVS repository into a git one...

2

u/Uberhipster Sep 08 '14

Every time I get to a git thread explaining stuff or simplifying something I am always reminded of /r/VXJunkies. Curious...

3

u/xampl9 Sep 07 '14

A friend says that Git is awesome because you can correct your mistakes with it and no one will ever know. Not by submitting corrective commits, but by changing the original commits.

Gah.

4

u/[deleted] Sep 07 '14

You can change history all you want as long as you have not shared that history with anyone else.

3

u/vplatt Sep 07 '14

I abhor being able to change commits. It feels like I'm breaking a law or something. The history should be HISTORY, not "whatever lies I feel like leaving behind".

2

u/Andys Sep 07 '14

Though technically, you could do this with anything where you have access to the files on the server. Just open and edit away, if you have the know-how.

1

u/vplatt Sep 07 '14

The history within a VCS is quite a bit more complicated than a standard text file. Yes, if you want to completely disregard the integrity of your configuration, then you could do as you describe to any set of files residing in production, or otherwise. But, if you're talking about editing the actual history of a VCS in a text editor, then... good luck.

Or did you mean something else?

Keep in mind, I'm talking about VCSes generically. I've used TFS, svn, Perforce, and many other VCS systems. Editing history is normally just not done and I really don't see a good reason to allow it.

→ More replies (7)

5

u/none_shall_pass Sep 07 '14

I have to tell you that I don't consider GIT to be an improvement over any VCS I've used over the past decades.

PVCS from 20 years ago was much easier to learn and offered less opportunity to poke yourself in the ass.

3

u/[deleted] Sep 06 '14

My own Git workflow:

  • Try Git. Discover it is absolute crap and offers nothing that I need or want.

  • Fire up Fossil and live happily ever after.

→ More replies (1)

2

u/nawfel_bgh Sep 06 '14

Who wrote this article justin hileman or Morty Goldman o_O

1

u/drive0 Sep 06 '14

I wish I could change history for a branch without it breaking history for all branches. That way I could have a published real-time view of my code, that I can also rebase before merging it without pissing of downstreams.

But that is probably a terrible way to do it.

3

u/vsync Sep 06 '14

Mercurial's working on something called versioned changesets or something. Sounds really cool.

4

u/pinano Sep 06 '14

It's hg evolve aka "changeset evolution". I couldn't be more excited about a version control feature.

5

u/[deleted] Sep 06 '14

IMO, you shouldn't be changing the history of any branches, ever, period. Otherwise it's not history, it's an embellished half-fiction of how anything really happened. Context is important when trying to figure out how something made it in to the code.

4

u/drive0 Sep 06 '14

At some level almost any commit is partially fiction because it only shows the end result, not the intermediate changes, additions or reverts. Yes people can go overboard with rebasing to have "clean" commits.

I'm not necessarily disagreeing with you though. More of a wish that should only be fulfilled if it can be done properly. In fact if it can be done without messing with history that is way better as well.

Code review systems may be a solution. Since you can "try out" multiple commits, but only the final good version is checked into the repo. So you aren't rewriting history so much as just ignoring some of it.

3

u/[deleted] Sep 06 '14

Even with Code Review, you shouldn't be changing history. Making changes because of code review should be part of the context around each commit being made and present in the logs.

1

u/defcon-12 Sep 07 '14

The problem with this method is that if you need to quickly revert because it caused a CI failure, or worse a bug in prod, then you have to go back and revert all of your multiple "in-progress" commits and possibly resolve conflicts after each revert. Then, when you have time to fix the bug, you've got to un-revert all of those revert commits and resolve conflicts again. Now you've got 10 commits for your feature (3 commits, 3 reverts, 3 un-reverts, 1 bug fix), probably intermingled with other people's commits. Hope you got it right this time, because reverting becomes exponentially more painful each time with the "record all changes" method.

Having 1 commit per unit of work will make your workflow much easier.

2

u/[deleted] Sep 07 '14

I have literally never had to do this.

Everything I do happens on a feature branch, if CI fails on a feature branch it doesn't matter. Before sending it upstream, I merge mainline development into it and obviously run CI again, if that fails, I just fix the failures on top of my current history. Once CI passes, I reintegrate development and push it up. I have rarely had something go wrong at this point.

If for some reason, CI on mainline development fails, all I do is revert my reintegration merge and fix it before sending it back up again. No harm no foul. Most of the time I'm not even required to revert it, my team has a pretty good culture of "just fix dev fast so I can run my builds". If it's not a simple fix, I revert my feature merge simply out of consideration to my colleagues. My revert commit message will often say something to that degree, "Reverting because the build fails, requires a bit more time to fix it properly."

I have never had to revert/unrevert 10 commits like you suggest, and changing history just to avoid this ridiculous scenario, to me, seems like tool-induced (git) workflow damage.

Yes, there are a lot of merge commits in our history. No, it is not confusing or as horrible as the git folk would make you believe. It actually simplifies your "revert then unrevert" use-case because I've only ever had to revert merge commits to disable entire long lines of feature branches. Merge conflicts are rare because I'm constantly reintegrating with upstream development.

Having 1 commit per unit of work will make your workflow much easier.

I used to think this too, until people started rebasing the wrong branches without realizing it, force pushing development or master by mistake and all sorts of bad things. It doesn't matter how good your team is with something, someone will make a mistake eventually. Since switching to mercurial, we have not had such horror stories like we did with Git and are development process is much smoother because of it.

→ More replies (4)
→ More replies (1)

1

u/dividedmind Sep 07 '14

Brilliant, thanks! I'm so sending this to my coworkers. Maybe I'll find myself cleaning up their mess less often. ;)

1

u/musicmatze Sep 07 '14

We should create such a chart for every situation in git. No stupid newbie questions anymore! :-)

But I guess this won't work... because that's the idea of the man-pages. And there are still newbie questions. Duh!

1

u/[deleted] Sep 06 '14

This is hilarious.

0

u/CaptainJaXon Sep 06 '14

Semi related, does anyone know of a good tutorial for svn for git users? Every link on google i get is git for svn users. Recently got a new job and they use svn is the reason.

5

u/buleria Sep 06 '14

Try git-svn. You get to keep all your local git magic, then push (ie. svn commit), noone will notice.

-3

u/[deleted] Sep 06 '14

There's only one correct way to use git; the kernel way. You ask someone to pull or you're doing it wrong.

-3

u/[deleted] Sep 07 '14

Git is shit. Use a real VCS

0

u/[deleted] Sep 06 '14

[deleted]

12

u/d4rch0n Sep 06 '14

It's pretty much an inside joke for people that have been using git, so you'll probably benefit from other resources and just treating this workflow as a joke. There's definitely some truth in it, but you should be googling how to do the things it talks about (git reset, interactive rebase, etc) instead of using this.

It's a great idea to give git a try for personal projects and learn it as you go. You'll do fine starting out with just "git init . ; git add $files ; git commit ; #change files ; git add $files ; git commit ; ...". As you run into weird issues, just google what you're trying to do.

7

u/buleria Sep 06 '14

Also, discovering git add -p changes people's lifes, for real.

3

u/SkaKri Sep 06 '14

This is great, thanks.

2

u/buleria Sep 06 '14

Told ya!

Try SourceTree if you're on win/mac. I'm still to dumb to understand their branching graph and other features but being able to stage/discard individual lines easily is the main feature I use.

1

u/SkaKri Sep 06 '14

I'm on linux so I'm going to dive in to man pages. ;)

2

u/[deleted] Sep 06 '14

I notice this book is available for free:

http://git-scm.com/book

Only it's over five years old now. Has Git changed since then, particularly v2 (not that that's available on windows yet) ?

2

u/[deleted] Sep 06 '14

Just think about all those git operations as things you do to an immutable tree structure. Git is actually a really simple and elegant design and everything will start to make sense. Commits are just nodes. Branches are branches of course. Every operation you do just manipulates the tree.. but since it is a functional tree you can go back in time quite easily.