Live data from Hacker News

Understanding the Git Workflow

sandofsky.com

51–60 of 78 posts

Re: Understanding the Git Workflow

#51
post #42

Git is plain scary. We should stick with SVN.

Personally I find the "git isn't enough like SVN" argument to be basically the "I stick with Windows because Linux is scary" or "MacOS X sucks because I tried it once and none of my Windows shortcut keys worked."

It basically comes down to:

1) You probably shouldn't just dive into git if you don't have someone that does know it to help you out (or unless you're willing to go seek out help from mailing lists, irc, etc).

2) You shouldn't assume that just because RCS/CVS/SVN are the only VCS's that you've ever used that it means that's what all VCS's should look/work like.

Re: Understanding the Git Workflow

#52
post #47
post #42

Git is plain scary. We should stick with SVN.

Try http://hginit.com for a fantastic introduction to Mercurial for people familiar with SVN (or not). Git was designed to suit kernel development (as shown in the article). For us simple-minded mortals who like SVN, it is much easier to migrate to Mercurial.

Good article, well written. If we are to start using distributed version control then I guess it might as well be git since it seems to have the most traction in the press.

Re: Understanding the Git Workflow

#53
I'm wondering how people address one of the scenarios raised in the post, specifically this:

"It’s safest to keep private branches local. If you do need to push one, maybe to synchronize your work and home computers, tell your teammates that the branch you pushed is private so they don’t base work off of it.

You should never merge a private branch directly into a public branch with a vanilla merge. First, clean up your branch with tools like reset, rebase, squash merges, and commit amending."

I'm wonder how people address cleaning a private branch that has been pushed (when your goal is to get its changes into master cleanly). Rebasing the private branch is pretty much out of the picture since it has been pushed (unless you don't care about pushing it again). I can see some ways of doing this:

1) You could do a diff patch and apply it master, then commit.

2) You could checkout your private feature branch, do a git reset to master in such a way that your index is still from the private, then commit it. Ex:

currently on private branch git reset --soft master

Now all the changes from the private branch are changes to be committed on master. This is easy, but it puts everything in one commit.

If you wanted to do a few commits for different, but stable points, but you already pushed the private branch and can't rebase it, you could instead do "git reset --soft" on successive points in the private branch commit chain, committing to master as you go.

If you wanted to reorder commits from the private branch, I guess you could rebase the private branch (which means you can't push again since you pushed it already), then do the tactic from the last paragraph, then ditch the private branch cause it's no longer pushable.

Does anyone have better ways of putting changes to master for private branches that have already been pushed?

Re: Understanding the Git Workflow

#55
post #29
post #25

Earlier quoted context omitted.

I dunno, I think the claim that those commits "waste time" (in the sense of any meaningful amount of time, even cumulatively) is a little hyperbolic. I guess you view history differently than I do: I consider all development history to be "public history" regardless of whether it was pulled in from a clone or not. If you commit it to a repository I am going to be fulfilling a pull request from, I want the history the…

and you will get that history. But you will get it in the form that I would like you to have it, not as it happened. But there is no way for you to know besides the fact that all commits you are going to pull are self-contained and none of them breaks the build. Would you reject perfect looking commits, self-contained, perfectly documented and forming a perfect temporal history based on the fact that they are too per…

> But you will get it in the form that I would like you to have it, not as it happened.

And that's actually a very large part of why I don't use something that makes rebase easy. Because, fundamentally, I do not care how you "want" me to get it. I want to get it how it was put into the repository to begin with. I want to get it how it was committed--because how it was done matters to me, as a developer and as a person. This is an entirely emotional position and I don't care: show me how it was done. It matters to me, and given my personal axioms there is a decent argument, in my mind, that doing otherwise is disrespecting people who might want to see how you "put it all together."

You're certainly welcome to disagree. But because I use Hg for my projects and for any project I contribute to, and because my usual co-workers aren't going to go through the hassle of enabling Hg's rebase extension and using it just for the hell of it, I generally get what I want in the areas I care about. =)

Re: Understanding the Git Workflow

#56
post #50
post #30

Earlier quoted context omitted.

I completely agree with this. If a change was worth committing then it is worth sharing that commit with everyone. Otherwise you run the very real risk of loosing important information about the design of a feature the bugs that were found and addressed during development. Every change should been accompanied by a well described commit message and big changes are much harder to review. I can see a very small positive…

> If a change was worth committing then it is worth > sharing that commit with everyone You're misunderstanding some of the workflows that people are discussing. Sometimes I commit things that are half-finished, or even half-baked because I know that when it comes time to push I can rewrite things into a set of commits that makes sense. This workflow makes sense because rewriting is easy enough. Obviously, I might no…

My point is that these interim commits are useful information for other people too not just you.

They help show how the feature developed, what other implementation ideas you tried along the way etc.

Re: Understanding the Git Workflow

#57
post #3

The minute I learned about "rebase -i" and "add -p" has changed how I think about commits. I learned how I could easily keep the history clean and conversely, I learned the huge value that a clean history has for maintenance. Now, building the commits as self-contained entities that don't break the build in between not only helps me while searching bugs later on, it sometimes helps me detect code smells around unneed…

You will probably enjoy 'checkout -p' and 'reset -p' as well (revert and unstage changes hunk-by-hunk)

Re: Understanding the Git Workflow

#58
post #23
post #20

Earlier quoted context omitted.

What exactly does Mercurial do differently that is better?

Short of explicitly installing a rebase extension, it simply does not allow you to do this sort of mucking about with the commit history. For "oops, typo" commits, you can very quickly (and I mean, "it's a button in Tortoise" quickly) roll back your change and keep it in abeyance until you've fixed the typo.

Then what's the difference? You were talking about how you preferred uneditable histories, why does only rebase count?

Re: Understanding the Git Workflow

#59
post #56
post #50

Earlier quoted context omitted.

> If a change was worth committing then it is worth > sharing that commit with everyone You're misunderstanding some of the workflows that people are discussing. Sometimes I commit things that are half-finished, or even half-baked because I know that when it comes time to push I can rewrite things into a set of commits that makes sense. This workflow makes sense because rewriting is easy enough. Obviously, I might no…

My point is that these interim commits are useful information for other people too not just you. They help show how the feature developed, what other implementation ideas you tried along the way etc.

How are they useful? Why would anyone care about how you developed a single bugfix or a feature?

In your model, often the commits are not even sequential in the log because you might find a mistake only after committing several other changes. I can't see how not rebasing makes commit history better in any way at all. I would like to hear your reasoning.

The way I see it, instead of a series of commits that implement something, you could have a single patch (commit) that implements something, making it much easier to

0) find all the code that implements a certain feature, because it's a self-contained commit,

1) find bugs via bisection,

2) port to other versions via cherry-picking and

3) read the changelog and figure out what the hell is actually happening because there are no trash commits around obscuring things.

EDIT:

Just to clarify, I do not think that this is a matter of opinion or preference. That would imply that both approaches are equally valid.

I consider rebasing a tool that enables a vastly superior workflow. I have given a few reasons why I think it is superior and I am interested in counterarguments or at least reasoning as to why not making perfect commits (to the best of your ability) is preferable or even acceptable at all.

Re: Understanding the Git Workflow

#60
post #14
post #10

This is the first argument for using rebase that I've found truly convincing - really worth reading. This will probably change the way I use git.

It wouldn't mine, if I used git (I avoid git specifically for this reason, actually, and use Mercurial). If you're actually looking at your commit logs, I find that rolling back is trivial; I can't remember the last time I accidentally rolled back into an incremental commit. Personally it feels more like an apology for git's bad behavior than a good method of development.

"I can't remember the last time I accidentally rolled back into an incremental commit."

I can't remember the last time I had a heart attack and died, but that doesn't mean it isn't going to happen in the future to me or to someone else. It sounds like it's just good practice for a public repository too, since your not the only one with access to it.

Post reply on HN