Some notes on using git.

Options

Set your user name:

git config --global user.name "Example"
git config --global user.email "example@example.org"

Set other nice options:

git config --global alias.ad add
git config --global alias.bi bisect
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.dif diff
git config --global alias.he help
git config --global alias.ini init
git config --global alias.pul pull
git config --global alias.pus push
git config --global alias.st status
git config --global color.branch auto
git config --global color.diff auto
git config --global color.interactive auto
git config --global color.status auto
git config --global color.ui true
git config --global core.editor vim
git config --global format.pretty oneline

Tricks

To configure a remote a merge branch for each branch: (let say you changed the location of the central repo)

git remote rm origin
git remote add origin https://aalex@github.com/aalex/spinic.git
git config --add branch.master.remote origin
git config --add branch.master.merge refs/heads/master

If there are many branches, no need to fetch them all, there are already cloned, but you need to list all branches:

git branch -a 
git checkout otherbranch

To create a tag:

git archive --format=tar --prefix=spinic-0.1.1/ 0.1.1^{tree} | gzip  > spinic-0.1.1.tar.gz

To import an existing project as a subtree to current project(source: http://www.kernel.org/pub/software/scm/git-core/docs/howto/using-merge-subtree.html):

git remote add -f Bproject /path/to/B <1>
git merge -s ours --no-commit Bproject/master <2>
git read-tree --prefix=dir-B/ -u Bproject/master <3>
git commit -m "Merge B project as our subdirectory" <4>
git pull -s subtree Bproject master <5>

1. name the other project "Bproject", and fetch.
2. prepare for the later step to record the result as a merge.
3. read "master" branch of Bproject to the subdirectory "dir-B".
4. record the merge result.
5. maintain the result with subsequent merges using "subtree"

git (last edited 2011-06-23 23:00:36 by Michal Seta)