Git Cheat Sheet

This page is my Git cheat sheet. If you find it useful too, hooray!

Creating new repositories

On your local machine:

mkdir /path/to/new-repository
cd /path/to/new-repository
git init
edit .gitignore # use .gitignore contents shown below
git add * .gitignore
git commit -m "Created local repository."

As root on the Trac server (or use sudo):

cd /var/git
mkdir new-repository.git
cd new-repository.git
git --bare init
git config core.sharedrepository 1
git config receive.denyNonFastforwards true
chmod -R g+ws *
chmod -R 777 *
chown -R gitadmin:gitadmin *

Back on your local machine:

cd /path/to/new-repository
git remote add origin ssh://user@git.server.com/var/git/new-repository.git
git push origin master
git checkout origin/master
git branch -f master origin/master
git checkout master
git commit -a -m "Completed repository setup."
git push

Tags

Creating tags

git tag tag_name
git push --tag

Deleting tags

git tag -d tag_name
git push origin :refs/tags/tag_name

Standard .gitignore file

# IDE crap
/nbproject
/.settings
/.buildpath
/.project
# Mac OS crap
.DS_Store
._.DS_Store

 

Social Widgets powered by AB-WebLog.com.