Using Git
Getting started with git
1. Set up global config
git config --global user.name "USERNAME"
git config --global user.email user@mail.com
Can also do this per repository:
cd /path/to/repo
git config user.name "USERNAME"
git config user.email user@mail.com
Map authors if using git-svn:
git config --global svn.authorsfile ~/.authors
Format of .authors is: svn_name real_name <email>
For Github:
git config --global github.user USERNAME
git config --global github.token GITHUB-TOKEN
- should also add public key of machine to Github account
2. Create local git repository and do work
If coming from SVN: use git-svn.
See git-svn cheatsheet
# Clone a repo (like git clone):
git-svn clone http://svn.foo.org/project/trunk
# Enter the newly cloned directory:
cd trunk
# You should be on master branch, double-check with git-branch
git branch
# Do some work and commit locally to git:
git commit ...
# Something is committed to SVN, rebase your local changes against the
# latest changes in SVN:
git-svn rebase
# Now commit your changes (that were committed previously using git) to SVN,
# as well as automatically updating your working HEAD:
git-svn dcommit
# Append svn:ignore settings to the default git exclude file:
git-svn show-ignore >> .git/info/exclude
Otherwise - set up new git repo.
git init # initialise
git add . # add directory (or file)
git commit # and commit
# do some work...
# (git add, git rm, git mv)
# then commit
git commit -a (-m for message, -e to edit message)
# stuffed up?
git commit --amend
# really stuffed up?
git reset HEAD^
3. Browse changes
Numerous commands for this.
- e.g. git log, git status, git diff etc.
4. Work with remote repositories
Set up the remote repository:
- on Github - web form
- on own server





