My Git Workflow
gweezlebur.com
gweezlebur.com
I say this as someone who's just beginning to see the amazing possibilities with quick branching. I've started working on all new features in their own branches and it's really making my life easier. I used to do a limited form of that in Darcs, but I just ended up with so many directories it got unworkable. With Git it's all neatly tucked away and I have Emacs and my shell set to always display the branch I'm working in so I never (ok, almost never) get confused.
It's like the old saying that anyone can learn Lisp in a day, but it'll take three days if you already know C. Anyone can learn Git in a day, but it'll take three if you already know SVN.
Yes, I know it's a book on a commercial vcs and doesn't directly have anything to do with Git. But ClearCase with UCM has an equally powerful branching capability and in some ways is easier to use and manage (from a developer perspective). And there's probably at least 10 years of development and actual large-scale use behind it. It's good stuff, or at least the theory and workflows (just tune out the CC implementation parts).
FYI, my background was as a consultant in enterprise version control dealing with a number of different products: PVCS, Dimensions, Harvest, Starteam and ClearCase. All centralized and all working in completely different ways. I'd spent over three years on ClearCase architecting, implementing and managing a large-scale deployment before picking up Git.
Instead of giving them 15 commands to try to figure out, you hand them three. When they get these three, you give them another situation and hit them with more functionality.
Had I known that I could do most of my Git work with a couple commands, I wouldn't have spent two days reading every last thing about Git I could find.
There's a couple of other good tidbits in there if you're still a git neophyte like myself.
# git stash (all my changes are saved away, and I have a clean tree)
# Fix the bug
# git commit -a -m "bugfix"
# git stash pop (changes are back)
This is the type of stuff that make SVN people "get it".
Otherwise, I use a new topic branch instead of stashing. Branching takes so little effort.
git branch -m origin github
git remote rename origin github
Had branches on the mind and didn't catch it till just now and the edit window is closed.
For the most part you can tweak most of the configs via command-line: git branch, git remote, or git config. I switch between those and editing the .git/config directly depending on the scope of the changes.
Recently I've been transitioning to a workflow a little more like his second one, and I see the benefits, it's just hard to remember the commands and what sequence they need to be executed in.
Some good info in the article, though I think these comments have some better stuff.
"git rebase --interactive HEAD~10" will bring up a $EDITOR window with the last 10 commits listed. You can rearrange them, squash them into each other, delete some entirely. Save the file, and git will happily rewrite history for you.
See this blog post for a little more detail: http://blog.madism.org/index.php/2007/09/09/138-git-awsome-n...
[alias]
magic = rebase -i HEAD~10
Then you can just use 'git magic' instead of writing the full command.Then again, I have an alias "git cia" for "commit -a"... Just remember where to look it up if you need something more elaborate.
I always use
git rebase --interactive origin/master
That only shows me commits that are local.It's always seemed so much effort than it's worth.
Besides, isn't it better to keep a history of what actually happened? Something about being doomed to repeat it comes to mind...
That's only useful for me, during tight development loops, not to a historian looking back at what I actually did. So before I push to others, I squash it to a changeset, possibly keeping all the commit messages in the single commit.
That way you can branch at any point in the commit history and be sure it'll run cleanly or cherry-pick a change without having to remember everything that it might depend on. And you get exactly what you want and nothing more.