Skip to main content.

4.6.2. An Introduction to git

git basics

good introduction: Randall Schwartz on git

Working with existing repositories

introduce yourself:

$ git config --global user.name "Your Name Comes Here"
$ git config --global user.email you@yourdomain.example.com

clone a repository:

$ git-clone git://www.denx.de/git/linux-2.6-denx.git

look at the history

$ git-log     # simple
$ tig         # tui

add a branch for hacking

$ git-checkout -b hacking HEAD

edit some files and look at changes in working dir

$ git diff

add modified files to the index:

$ git add file1 file2

delete some and mark them as deleted:

$ git rm file3

look at diffs of the modified files added to the index

$ git diff --cached

get some general statistics of which files were modified:

$ git status

to throw away the changes git reset HEAD, to reset the working directory git-checkout -f

commit the changes added to the index (will be prompted for commit message)

$ git commit    # -s adds Signed-off-by: ... line

alternatively without using the index as an intermediate stage:

$ git commit -a

unhappy with commit message?

$ git commit --amend

local branches

what branches have we got?

git branch

create a branch as a clone of the current branch:

$ git branch hacking

check out the contents of this branch:

git checkout hacking

hack around, make a mess of it and decide to throw it away

git checkout -f
git checkout master
git branch -d hacking

git for developers

Example: rework last 5 commits

$ git-rebase --interactive HEAD~5

move around lines and change pick into squash in order to merge commit into previous one.

$ git rebase --abort

goodies

4.6.1. The powerful U-Boot command line interface 1. Denx Training Topics 4.6.3. Building U-Boot
Prev Home Next