Difference between revisions of "GitPhraseBook"

From Openembedded.org
Jump to: navigation, search
(typos)
Line 1: Line 1:
= Git Phrase Book =
+
= Adding missing Checksums =
  
  
'''NOTE:''' For increased pleasure use git 1.5 or later.
+
* go to TMPDIR and locate the checksums.ini there
 +
* combine the checksums.ini from OE and yours:
 +
  cat TMPDIR/checksums.ini >> OE/org.openembedded.dev/conf/checksums.ini
  
== Pointers ==
+
* sort the result and apply it to OE
There are plenty of good git tutorials on the net. A small collection of links can be seen below:
 
  
* [http://git.or.cz/gitwiki/GitDocumentation Official Documentation]
+
cd /OE/org.openembedded.dev/conf/
* [http://git.or.cz/gitwiki/GitCheatSheet Cheat Sheet]
+
python ../contrib/source-checker/oe-checksums-sorter.py checksums.ini >tmp
* [http://eagain.net/articles/git-for-computer-scientists/ Git For Computer Scientists]
+
mv tmp checksums.ini
* [http://www.google.com/search?q=git+documentation&ie=utf-8&oe=utf-8&aq=t Google Search]
 
  
== Setup ==
+
* inspect the results:
  
 +
git diff checksums.ini
  
=== Getting the data (read-only) ===
+
The diff should only contain additions (removals and replacements are a sign of corruption somewhere).
  git clone git://git.openembedded.net/openembedded
 
 
 
=== Getting the data (write-access) ===
 
 
 
For this command to succeed you need to have provided a SSH key (see [[#Generating a ssh key]]).
 
 
 
  git clone git@git.openembedded.net:openembedded
 
 
 
=== Generating a ssh key ===
 
To be able to push to the OpenEmbedded git server you will need to have the right permissions. This starts with having your public ssh key on the server. Generate a key and send the public key to the one of the core developers.
 
 
 
  # send the resulting pub key to koen, mickeyl, RP, or zecke [http://lists.linuxtogo.org/pipermail/openembedded-devel/2008-October/006291.html [email address]]
 
  ssh-keygen -t rsa or -t dsa
 
 
 
=== Upgrading your data (lurking) ===
 
  git pull --rebase
 
 
 
This command will fetch new objects from the server, and try to put your local changes on top of the newly fetched revisions for your current branch. If you have no local revisions you will still be updated.
 
 
 
=== Checking out a branch ===
 
  # See which branches are available
 
  git branch -a
 
 
 
  # In theory create a branch and switch
 
  git checkout -b local origin/remote
 
 
 
  # you will now be in the dreambox branch and track this.
 
  git checkout -b org.openembedded.dreambox origin/org.openembedded.dreambox
 
 
 
=== Configuring your tree for commits ===
 
 
 
If you forget this, your name and email in the commit mails, may be messed up.
 
 
 
  git config user.name "Your Name"
 
  git config user.email "you@name"
 
 
 
== Doing things with git ==
 
 
 
=== Commit Message ===
 
<package name> <version>| <package category> | <configfile/class name>: <summary>
 
{  - <detail 1>
 
    - <detail 2>}*
 
 
 
=== Making your changes (old way) ===
 
  # if you have new files
 
  git add your/new/file
 
 
 
  # Commit everything
 
  git commit -a
 
 
 
=== Making your changes (better way) ===
 
  git add your/changed/files
 
  git commit
 
 
 
=== Making your changes (a cool way) ===
 
  git add -i
 
  git commit
 
 
 
=== Amending to your changes ===
 
You forgot something, no big deal, change the commit
 
 
 
  git add your/others/changes
 
  git commit --amend
 
 
 
== Commiting someones else work ==
 
  git commit --author "Other One <other@one>"
 
 
 
== Pushing your changes ==
 
  # just pushes the org.openembedded.dev
 
  git push origin org.openembedded.dev
 
 
 
  # the same, just simpler
 
  git push
 
 
 
  # just pushes your things to a test branch. Use the right branch! dangerous!
 
  git push origin org.openembedded.dev:yourname/testbranch
 
 
 
  # delete a branch
 
  git push origin :yourname/testbranch
 
 
 
== Dealing with conflicts ==
 
Git will tell you what needs resolving. You can use kdiff3, meld, or many other tools to resolve the conflict. Don't be afraid you can easily redo and undo everything.
 
 
 
  # Conflicts from here or something else
 
  git pull --rebase
 
  git status
 
 
 
  # Starts interactive resolver, TOOL can be kdiff3, meld or anything else
 
  git mergetool --tool=TOOL filename
 
 
 
  git rebase --continue or similar once everything got resolved
 
 
 
== Working with git ==
 
=== Feature branches ===
 
==== Create your own short lived feature branch ====
 
  git checkout -b yourname/yourfeature origin/org.openembedded.dev
 
 
 
==== Push your feature branch ====
 
  git push origin yourname/yourfeature
 
 
 
==== Delete your branch after it was merged ====
 
  git push origin :yourname/yourfeature
 
 
 
==== Upgrade/Rebase your branch to the latest version ====
 
  git fetch origin
 
  git rebase origin/org.openembedded.dev
 
 
 
==== Change your history ====
 
  # select edit, squash, pick to say what to do with the commit
 
 
 
  git rebase -i origin/org.openembedded.dev
 
 
 
  # to abort the operation on a tricky merge
 
  git rebase --abort
 
 
 
  # to find out a previous state to use with git reset
 
  git reflog
 
 
 
== Seeing changes ==
 
 
 
=== Log ===
 
  # See what happened in a branch
 
  git log branch
 
 
 
  # See the change, HEAD or branch name will work too
 
  git show --color (COMMIT)
 
 
 
  #  Only show you change on foo/file
 
  git show --color HEAD -- foo/file
 
 
 
  # Graphical browser
 
  gitk
 
 
 
=== What did you change ===
 
  # Lists you the revs that are only in your branch compared to org.openembedded.dev
 
  git rev-list origin/org.openembedded.dev..
 
 
 
== Other Interesting commands ==
 
  # fetch new revisions from all remote repositories
 
  git fetch
 
 
 
  # show your local branches and which branch you are in
 
  git branch
 
 
 
  # show your all branches
 
  git branch -a
 
 
 
  # create a branch and switch to it
 
  git checkout -b MYNAME origin/THEIRNAME
 
 
 
  # upgrade a branch
 
  git push origin org.openembedded.dev
 
  git reflog
 
 
 
  # Change your index to be at the state of REF
 
  git reset REF
 
 
 
  # Kill the last commit
 
  git reset HEAD^1
 
 
 
== Working with additional git repositories ==
 
One of the neat things with git is you can easily work with external repositories. 
 
  # add an external repository:
 
  git remote add openmoko.org git://git.openmoko.org/git/openmoko.git
 
  git fetch openmoko.org
 
 
 
  # view all remote branches available
 
  git branch -r
 
 
 
  # view changes on a remote branch
 
  gitk openmoko.org/org.openmoko.asu.stable
 
  git log openmoko.org/org.openmoko.asu.stable
 
 
 
  # view all diffs
 
  git diff origin/org.openembedded.dev openmoko.org/org.openmoko.asu.stable
 
 
 
  # view diffs in just one subdirectory
 
  git diff origin/org.openembedded.dev openmoko.org/org.openmoko.asu.stable classes
 
 
 
 
 
== Examples ==
 
 
 
 
 
=== Example 1: ===
 
 
 
  vi packages/gaim/gaim.inc
 
  git commit packages/gaim/gaim.inc
 
  git pull --rebase
 
 
 
should have a log message like this:
 
 
 
gaim: make sure do_install does its job in gaim.inc
 
* install lib to ${libdir} instead of /usr/lib
 
* remove executable bits from docs
 
 
 
=== Example 2: ===
 
 
 
diff /tmp/foo.c /oe/work/gtk+-2.8.4-r0/gtk+-2.8.4/src/foo.c > gtk-2.8.4/fix-foo.patch
 
vi gtk+_2.8.4.bb
 
git add gtk-2.8.4/fix-foo.patch
 
git commit gtk-2.8.4/fix-foo.patch gtk+_2.8.4.bb
 
git pull --rebase
 
 
 
should have a log message like this:
 
 
 
gtk+ 2.8.4: add patch for buffer overflow
 
 
 
 
[[Category:Dev]]
 
[[Category:Dev]]
 
[[Category:User]]
 
[[Category:User]]

Revision as of 22:34, 15 October 2008

Adding missing Checksums

  • go to TMPDIR and locate the checksums.ini there
  • combine the checksums.ini from OE and yours:
 cat TMPDIR/checksums.ini >> OE/org.openembedded.dev/conf/checksums.ini
  • sort the result and apply it to OE
cd /OE/org.openembedded.dev/conf/
python ../contrib/source-checker/oe-checksums-sorter.py checksums.ini >tmp
mv tmp checksums.ini
  • inspect the results:
git diff checksums.ini

The diff should only contain additions (removals and replacements are a sign of corruption somewhere).