documentation:dev:scm:git
=>  Releases

Current version
Git/Latestdiff: 1.5.6

Latest Snapshots
Produced after each commit or rebase to new upstream version

GIT
RSBAC source code, can be unstable sometimes

=>  Events

No events planned

This is an old revision of the document!


Git

Git is the version tracking system used by the Linux kernel and increasingly many others. Why?

  • it is fast
  • it is compact
  • it is fully distributed
  • it is widely supported
  • it let us import upstream changes directly

A simple example: The current rsbac-2.6 svn/svk repository is 1.2G, the same git repository is 367M.

Getting started, setup the repository

Comming from SVN, SVK? Forget about the classical file structure. Git is fully distributed, thus every repository is your own. When you push your changes upstream, you are sending your differences for inclusion, you are not synchronizing with upstream. That's the difference.

Also: there are no trunk, tags, branches directories. Only branches! Tags are special commits which are immutable, included in the branches. They are not standalone branches.

Branches can be merged to each other. In fact, git is made to do that all the time.

Every commit is marked with a unique SHA1 sum. When you merge, common ancestors (identical SHA1 sum) are found, no matter which branch you are using, Linus tree, RSBAC tree, your friend tree.. if there's common ancestors they will be found and used!

The default branch is usually called master (instead of trunk) but not necessarily.

Setup

Defaults for commits:

# git config --global user.name "FirstName LastName"
# git config --global user.email "user@example.com"

Enable coloring (recommended):

# git config --global color.ui "auto"

Enable multi-core CPU detection:

# git config --global pack.threads "0"

Enable maximum memory usage limit (recommended for systems with 2G+ of RAM):

# git config --global   diff.renamelimit "0"

Fetch it (technically, fetch pull and checkout)

(As developper)

# git clone ssh://rsbac.org/daten/git/linux-2.6.git

(Anonymous)

# git clone http://git.rsbac.org/linux-2.6
# git clone git://rsbac.org/linux-2.6

Note that this gives you the same repository, but setup your git config file differently, so developers can push their changes by default via SSH. git: is faster than http:.

Fetch a remote branch

# git branch -a

[…]

remotes/origin/rsbac-1.4-2.6.33
# git checkout -b rsbac-1.4-2.6.33 origin/rsbac-1.4-2.6.33

Update your RSBAC kernel release (reference only, change values!)

This updates the 2.6.33 kernel "stable" branch
# git pull ssh://rsbac.org/daten/git/linux-2.6.git rsbac-1.4-2.6.33
This updates the master "unstable" branch (this will take both Linus tree changes and RSBAC changes)
# git pull ssh://rsbac.org/daten/git/linux-2.6.git master
Update the master with changes from Linus's Linux tree (=latest possible Linux kernel)
# git pull git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git

Solve conflicts

I suggest you install a merge tool, like vimdiff, meld, or kdiff.

# git mergetool

When solving, make sure you have a new line between RSBAC code and kernel code. This will allow future changes to be auto-merged more easily when possible.

The cheat sheet (this is where you find all common commands)

Ease up your tasks

Use a GUI log browser! For example: gitk or gitg, but there are many others.

This gives you a local version of “git web” basically.

Speaking of which, another must have the linux-2.6 master git web interface:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=summary

And the RSBAC one:

http://git.rsbac.org/

Advanced tasks

  • If your origin is rsbac.org and not kernel.org, you may want to add an additional remote branch to track:
# git remote add upstream git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
# git fetch upstream
# // You can now address this branch as upstream/master for diffs and merges
  • Diff against stable sub releases (2.6.33.2 for example)

Get the tags from the stable git repos:

# git fetch -t git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-2.6.33.y.git

And just diff it:

# git diff v2.6.33.2

Or diff with a RSBAC tag (to create a patch for one kernel version):

# git diff v2.6.33.2 v2.6.33.2-rsbac-1.4.4
  • Make a tag (from current branch/checkout)
# git tag -a my_tag_name
  • Signed tags

git is a bit stupid about tag signing. Yeah, really. If you use for example, kang@rsbac.org as your git commit email, you need to own a default primary gpg key with that email. If like me, you do not have that, but instead, kang@rsbac.org is an alias for another primary gpg key (=another email), you have to tell git or it won't find out, and it will look like your missing your private key while you're really not.

# git tag -u kang@rsbac.org -s my_tag_name

Recover the repository after a non-RSBAC commit

While this should not happen, it could be that you commit a non-RSBAC group of files in the Linux tree, which will break “fast forward” merging and conflict on non-RSBAC committed files while pulling from the Linux upstream (linux-2.6.git).

In that case, there is a solution:

  1. git clone git:git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 - cd rsbac-2.6 ; git checkout master #or whatever branch you need to fix - diff -uprN -x .gitignore -x autoconf.h -x rsbac -x Documentation/rsbac -x .git linux-2.6 rsbac-2.6 > /tmp/out.patch - rsbac-misc/scripts/checkhunks.py /tmp/out.patch 'diff -uprN' #check it doesnt find any non-rsbac change, else review your patch - cd linux-2.6 ; patch -p1 < /tmp/out.patch - cd linux-2.6 ; git pull -s ours ../rsbac-2.6 master #or whatever branch you need to fix - git status - remove all untracked files if any - they're not part of Linux anymore - remove all modified files with no rsbac code: * git status #edit and clear up by hand whatever is not a modified file (you can keep the original formatting, else next command lines will need to be changed also) * for i in $(awk '{print $3}' /tmp/a); do grep -i RSBAC $i > /dev/null || git checkout $i ; done - a new git status should give you all the files that are RSBAC related and still need to be committed - git diff > /tmp/b - rsbac-misc/scripts/checkhunks.py /tmp/b 'diff –git' #check it doesnt find any non-rsbac change, else review your files ! - check all remaining files by hand: * git status > /tmp/b #edit and clear up by hand whatever is not a modified file again * for i in $(awk '{print $3}' /tmp/b); do git diff $i > /tmp/a; vim -o /tmp/a $i; done * with this command you'll see a diff, “-” lines are the ones you need to add in the bottom (original) file (unless they're required to be removed for RSBAC code), “+” lines are the ones you need to remove (unless they're RSBAC code) * if you're using vim, don't use :wqa or the script will stop, just use :w then :qa - commit
//
documentation/dev/scm/git.1297783905.txt.gz · Last modified: 2011/02/15 16:31 by 127.0.0.1

documentation/dev/scm/git.1297783905.txt.gz · Last modified: 2011/02/15 16:31 by 127.0.0.1
This website is kindly hosted by m-privacy