Git Usage
Suppose you want to work with a git repository called test.git, here are the basic tasks you might be interested:
Contents
Clone A Repository
In Subversion, it is usually called a checkout, but for git, you do cloning:
git clone git@aicip.eecs.utk.edu:test.git
Now you should have a directory test created which has all the files and history ever recorded for this repository.
Add a new file and commit the changes
Say you want to add a new file into the repo.
git add mynew.cpp git commit -am "my new file"
Create a branch and make changes
Most of the time, you don't want to make changes to the "master" branch, or known as "trunk" in Subversion terms. You should create a branch of your own, and make changes right there.
git branch mytest git checkout mytest git add mynew.cpp git commit -am "make changes to my own branch"
Note that the previous commit only make changes to a local branch named mytest. To make your changes available to other collaborators, you need to make this branch remotely available. To do that, you need to push the branch to the remote:
git push origin mytest
Pull the changes
In Subversion terms, this is equivalent to "svn update" - when others have updated their stuff, you want to see that change, and that is the time to "pull" stuff:
git pull origin master
or
git pull origin mytest
The first command shows you can pull from the master branch. The second command shows you can pull from mytest branch. Exactly which branch you want to pull depends on how you and other decide to co-ordinate the editing activities.