Drinking The Git Kool Aid
Since Git first came out I've tinkered with it off and on with small personal projects but have always used SVN at work.
I recently got a new job and we are using Git, so I had to bit the bullet, RTFM and actually learn how to use it.
I was lazy and first tried installing a Git GUI - Atlassian SourceTree to be exact. I was used to always using TortoiseSVN with Subversion and was hoping for the same kind of experience with Git. But Git, compared to SVN is quite complicated and while at a very high level it does the same thing, how it does it is very different.
I was familiar with Git commit, push and pull and was able to do the very basics in SourceTree but I soon had issues that I couldn't easily resolve within the GUI and searching for solutions always referred to the command line.
The solution? Use the command line stupid.
Setup ConEmu and start using the Git shell. I won't say Git is more complex than SVN but there is more going on under the hood. By using the command line interface I had a much better understanding of what I was actually doing versus the point and click GUI.
There are tons of 'cheatsheets' online. I printed this one out and keep it handy on my desk. There are really only 4-5 commands you use regularly:
- git status - tell me what I've changed recently
- git add - add those changes files to git's 'staging' area
- git pull - get the latest changes from everyone else
- git push - send the latest changes to everyone else
- git commit - you know what that does hopefully
Git has very good help! You have two options:
- 'git status --help' will take you to an online reference about 'git status'
- 'git status -h' will simply print out the standard help within the console
And Git also usually gives you good feedback when using commands.
For example if you have some work in progress and do a 'git status' Git will tell you what you need to do next:
[D:\wwwroot\pelican]git status # On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: content/2013-05-13-installing-railo-coldfusion-iis.markdown #
As you can see above Git tells me I have uncommitted changes, and I can add them with 'git add' or I can discard them with 'git checkout'. Now if you need more info you can reference the help for 'add' or 'checkout'.
In our next post we will chug down another glass of Git Kool Aid and learn how to hook Beyond Compare up and use it as our favorite diff tool within Git.