[29021 views]

[]

Notes on git

These are my notes on git — the stupid content tracker. I am using git mostly to keep local Linux kernel sources. Here are the tasks that I normally need.

Checkout

To get Linus' tree:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux

To get another fork and use Linus' tree as a baseline to reduce traffic:

git clone --reference linux git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-stable

Update

To checkout a tracking branch:

git checkout -t origin/linux-3.0.y

To get the latest changes from the kernel maintainers:

git pull

To revert to the clean copy:

git reset --hard HEAD
git clean -f

List tags and remote branches

git tag -l
git branch -r

Local branches

Create local branch from tag. Useful to make a release:

git checkout -b <branch> <tag>

To switch between branches:

git checkout <branch>

To delete a branch

git branch -d <branch>

Release

Creating a tarball

git archive --prefix=linux-3.14/ -o ~/linux.tar.gz v3.14.19

Releasing to a directory

git archive --format=tar --prefix=linux-3.14/ v3.14.19 | (cd /usr/src && tar xf -)

Diffing

Create diff between tags:

git diff v2.6.18.1..v2.6.18.2 > patch.diff

Submitting patches

Export *.patch files
git format-patch -M master..<branch>
Email them:
git send-email --to=<recipient> *.patch
More on workflows