Friday, November 19, 2010

Getting started with Git

If you have a large shared software project and want an easy way to manage collaboration, branch off different versions of the project and generally keep things organized, you need a version control system. Git is the one I know (Mercurial and Subversion are also popular choices) and the one other people in the group are using, so it's the one I'll go over here.

Download git here:
Set up an ssh public key and register an account at (apologies to non-Mac users)
Enter the following at the terminal (with obvious substitutions):

export PATH
git config --global "Your Name"
git config --global

To pull a repository called "repo" from user "person":

mkdir repo (or what have you)
cd repo
git init
git remote add origin
git pull origin master

In particular, every call of "git pull origin master" pulls the currest master version off github. Be sure you're working with the current version before trying to push local changes, or you might get conflicts. To commit changes, either call

git add files_that_changed
git commit


git commit -a

which commits all changed files. Committing brings up a text editor where you describe any changes made. Be aware, if you don't write anything the commit will be aborted. Then to push your changes from the local machine to github just type

git push

and that's it! Things get messier when working with branches, checkouts and merges, but for 90% of what I do the above suffices. The web abounds with tutorials and a quick reference sheet can be found here.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.