After Denver WordCamp back in November and a really well-done presentation by Jeremy Green, I decided it was finally time to dive into Git.
As a mostly-solo developer, I’ve felt ambivalent about it, but I know that it’s very important, if not critical, when working with a larger team. So…
I got my OS version of Git here. I’m not much of a command-line person so I also checked out some of the GUIs – the one that I liked (not knowing anything about it yet except that it had a pretty nice UI) was SourceTree from Atlassian. Jeremy had talked about BitBucket being a good choice for hosting private repos, and Atlassian also makes BitBucket. Seemed logical.
Then I looked at some resources and started with this one: TryGit. I liked ts friendly UI and the step-through examples, it was easy to get going but it quickly got into more advanced areas (I’m not there yet). This was a good starting point.
So in the next WordPress project, I resolved to just jump in and do this. Note: this is super-basic – I’m only using this on my local machine at the moment, so bear with me. This is for total newbies.
I opened up GitBash (the included SSH editor), navigated to my project folder and typed in:
This creates a fresh new repository (repo) of project files.
Then I’ll work on stuff for awhile. I can check out what’s happening with Git by typing:
This will show me a list of all the files in my project that have either not been added to Git, or have changed since the last time I added them. To add a file to Git so that it’s monitored, type:
But it’s easier to just add all the files at once:
Then check status again and you’ll see a list of files that are staged – they’re ready to commit, which means adding them to the repository. To commit all the files in staging:
git commit -m 'My Initial Commit'
Name your commits anything you like, just make it descriptive. You can view all your commits with:
Then I work some more, and when I get to a point where I feel I can give my commit a different name (i.e. I’ve finished a task), I type:
git add -A
git commit -m 'This Other Task I Finished'
And so on. That’s it – very easy, not too intimidating with the command line, and you’ve removed so much risk with just these simple steps. I actually haven’t used the SourceTree GUI yet – for what I’ve done so far, I’m now happy with the command line.
Now that this process has become fairly automatic for me, my next step is going to be setting up a remote repo, probably with BitBucket, and learning how to do those parts of Git. And how to make branches.