I’ve been forced to switch from SVN to Git at work. The path has been difficult so far, but there’s a number of good svn to git guides out there, so I won’t really be posting about those. But, as a decent subversion user who’s been forced into git, I’d be remiss in not documenting the realizations I’ve had about the various workflow differences.
git clone url – this is used to pull files from a repo to your computer. This is the equivalent of hey, git, go and copy the main folder of this project to my computer and set it up for version control.
The following command have to be done in a project that’s under version control.
git branch – asks git to remind us which branch we’re on and which branches we have available, should we want to switch to them.
git branch mybranch – This tells git to create a new branch on your computer to which we can switch if we like.
git checkout mybranch – This tells the project to stop working with whatever branch it had and to use the new branch you’ve specified. If you’ve got uncommitted changes to files and you do this, git will prompt you of any conflicts.
git pull – This says, hey git, give me all of the most recent files from the server in the current branch on which I’m working.
git pull branch – This says, hey git, give me all of the most recent files from the server in the branch I’ve specified.
git add my.file – This tells git to start paying attention to the specified file. If you don’t do this, git will assume it’s not supposed to care.
git commit or
git commit my.file(s) – Tells git that the state of things is something we want to hang on to. This doesn’t do anything on the server. It just tells git that the way things are now might be something we want to push to the server later. We also have to correlate a checkout with a message.
git push – This takes every commit you’ve made and pushes them up to the server.