GIT Cheatsheet



To clone (i.e. copy) a repository.
git clone ssh://esguerra@dnagit.rutgers.edu:1789/~/Documents/Thesis
To check the status of the project.
git status
To add files to the project.
git add .
To commit changes to the project.
git commit -m "Commit message here" 
To go back to an old version of the project. Note that the commit-ref is the SHA value in your git log
git checkout [commit-ref] [filename]
To add keys to gitosis repository
git clone gitosis@homegit:repositories/gitosis-admin.git
cd gitosis-admin
cp ~/.ssh/napoli_rsa.pub keydir/
git add keydir/napoli_rsa.pub
gedit gitosis.conf                 #Add user/key to authorized projects.
git commit -a -m "Grant Rights to Napoli to Thesis"
git push
cd localrepository/thesis
git remote add origin3 gitosis@homegit:repositories/thesis.git
git push
firefox http://homegit:8000/viewgit

- Notes

One can now create an account in a free git repository with private and public projects. There are many options for this nowadays, but the most popular are still github and bitbucket. You can find bitbucket at:
http://bitbucket.org
You can just upload your ssh keys and you're ready to go.
For example:
git init
git add .
git commit -m "initial import"
git remote add origin_1  git@bitbucket.org:esguerra/end2end.git
git push origin_1 master
One can also create an empty git repository like so:
mkdir nameofrepo
cd nameofrepo
git --bare init
You can also add an additional option to make sure that the repo is shared to all members of the same group with:
git init --bare --shared=group
Once you've created the empty bare repo in a remote host, then you have to make your local project indexed by git and then you can push it to the bare git repository in your remote host.
cd project   #AT LOCAL MACHINE
git init
git add
git commit -a
git push ssh://myremotehost/~/nameofrepo master #AND THIS WILL PUSH TO REMOTE  
Note: In the last line notice that the push is done to master branch. If you want it to go automatically to your git repo, you gotta config .git/config first.

- Links

How to set-up a git repository in ubuntu with gitosis for web browsing.
https://help.ubuntu.com/community/Git

How to get .gitignore to work
get .gitignore to ignore files I.
get .gitignore to ignore files II.

How to share a repository where users share the same group.
http://kovshenin.com/archives/howto-remote-shared-git-repository/