Working with Git
For the past week and a half, I've been pushing myself to learn and use git. I think I'm using it enough now that I managed to integrate it into my workflow which is probably the thing you have to work through the most. At work, we have access to SVN, but I can't say that everyone uses it - I use it on some projects, but I really should be using it on all projects. At home, when I'm working on my own stuff, I hadn't been using it at all. Well, I'm making an effort to change that and I have an account on github.com ( Sorry, don't have any open source projects yet. :/ ) and I'm using it for a couple of side projects I have.
So, I thought I'd jot down some notes of what has been working well for me:
- Forget about the GUIs. Learn the command line. Download msysgit and use it. I'm on a windows box, so this is actually a rough sell as we all tend to be GUI-centric, but seriously... open up explorer and right click the folder and "Git Bash Here" - if you're familiar with linux style commands, you'll feel at home here. Type 'ls' to list directory, 'rm' to remove files, etc.
- Msysgit does have a git gui, but again, learn the command line. If anything does go wrong with GUI interfaces, you're going to have to resort to using the command line anyway.
- Once you've initialized your project and git is up and running, create a branch and leave master alone. I use "master" as my current stable "ok, I know everything works here." I use branches for new development or bug fixes. I think this is probably the hardest thing for people (working solo) to get used to in their workflow.
- So, in my current project, I have a user tracking app. "master" already has a working copy of the website, by typing 'git checkout -b tracking' in the command line, I'm basically creating and switching to the branch called 'tracking'. I get everything working there the way I want, at any point, if I seriously screw things up or things aren't going the way I'd like... I just simply blow it away or just switch back to master and create a new branch and start over again.
- If things are going the way I'd like and I get to a good stopping point and everything is working, I'll switch to the master branch by typing: 'git checkout master' and then merge my code from the branch to the master by typing: 'git merge tracking' and like that, my master branch now has new files and modified files I've worked on over in the tracking branch.
I'm still fairly new at all this and I know that I need to figure out tagging and such. I'd love to list out all the git references I've been using, but honestly I've just been typing git commands into my chrome window and letting google find those answers for me. There's a lot of other CFMLers in the community that have more git knowledge and they've been slowly posting them on their blogs.
I would also suggest getting familiar with git locally first before rushing off to sign up for a github account. Once you're familiar with all the commands locally, trying to work remotely will make more sense. I must have created a couple of test projects on github before I was comfortable with pushing or pulling from an external source. I mention this because working with remote branches and stuff can get a little obscure.