The hardest part for me, so far, about using git is to actually use it. I mean, I’m checking out branches, making changes and the like. But mentally I’m still in the mode of organizing file versions in my head and then futzing with command line stuff (mv
, `cp and the like), as opposed to using git to help me do that.
More recently I had a couple minor git revelations that indicate I’m starting to grok this whole VCS thing a little more.
The first came while working on my blogclient. I had switched branches and in the process, I thought I’d lost some of my changes. I quickly switched back to the prior branch and realized I hadn’t lost anything. I just needed to bring an updated version of the file from one branch into the branch I wanted to work with. With git, this is trivial. From the working branch, the command is a checkout of the file from the branch with the updated version:
git checkout *otherbranch* path-to-file
Technically, I think, the otherbranch
is a commit. For instance, if there’s a debug branch with multiple commits and the file is in the previous commit, then the branch is specified as debug^
.
Another recent instance where git really helped me out was while debugging a couple of things in the python-markdown project. I realized there were multiple solutions to handle the bug. After coming up with them, I was manually commenting code to test each fix. Then I realized I didn’t need to do that. I just needed to create other branches, implementing each fix in its own branch, and just switch between branches to complete the testing phase.
I even leveraged the file checkout to speed things along. The project has a test suite so I created the appropriate test files in one of the branches and then just sucked them into the other branch. No manual copying required.
In the scheme of things, these are pretty minor revelations. But at least I’m starting to more fully understand the usage of it. Clearly, I still have to organize the source in my mind and no VCS will do that for me. However, once organized the tools can be used to quickly manage that mental organization. Saving a lot of command line typing in the process. So, yeah, I’m starting to ‘git’ it.