GIT for mortals
- http://github.com/ - public repos for everyone?
- Distro workflow with git: http://blog.madduck.net/debian/2007.10.07_converting-a-package-to-git
- Carl Worth's Mercurial book chapter: http://cworth.org/hgbook-git/
- Git for computer scientists: http://eagain.net/articles/git-for-computer-scientists/
- Jon Loeliger: http://www.jdl.com/OLS/Git_Tutorial.pdf
- git clone git.imendio.com/projects/giggle.git
- http://keithp.com/blog/Repository_Formats_Matter.html
- http://www.kernel.org/pub/software/scm/git/docs/user-manual.html
- http://git.or.cz/course/svn.html
- http://linuxart.com/log/archives/2007/05/27/adventures-in-git/
- Linus talks about Git: http://www.youtube.com/watch?v=4XpnKHJAok8
- KRH on making a repo available: http://hoegsberg.blogspot.com/2007/06/setting-up-cloned-git-repo.html
- Decentralized revision control: http://www.beatniksoftware.com/blog/?p=74
- Explanation on --signoff: http://kerneltrap.org/node/3180
- Git-send-bugzilla: http://tw.apinc.org/weblog/2007/01/16#using-git-with-bugzilla
send a patch to bugzilla, similar to git-send-email
http://blogs.gnome.org/shaunm/2007/09/17/git-for-gnome/ http://blogs.gnome.org/shaunm/2007/09/18/git-for-gnome-take-two/
Carl Worth on "why git": http://lists.freedesktop.org/archives/cairo/2006-February/006255.html
Carl Worth on "maintaining Cairo with git":
http://lists.freedesktop.org/archives/cairo/2006-February/006335.html
- http://git.or.cz/gitwiki/GitGlossary
- http://git.or.cz/gitwiki/BlogPosts
- Installing a custom diff handler (e.g. for OpenOffice files):
http://git.or.cz/gitwiki/GitTips#head-1cdd4ab777e74f12d1ffa7f0a793e46dd06e5945
- Linus talks about Git's history:
http://git.or.cz/gitwiki/GitHistory Don't read it at the beginning. You'll understand it better later, when you have an inkling of what the index and the DAG are about.
SVN author on 80% of programmers: http://blog.red-bean.com/sussman/?p=79
Public hosting: http://repo.or.cz
Bad docs:
http://www.jdl.com/papers/Embrace_The_Git_Index.html - doesn't tell me what the index is good for (explains very clearly how add / commit work the index, but doesn't give me a useful use case). (linked from http://www.jdl.com/)
It says at the very end, "More can be learned about merging and the internal workins of the Index itself by reading the git-read-tree and git-diff-tree documentation." But those docs are very technical! They look like a description of algorithms (which I don't care about), not about useful use cases.
Get git
git clone git://git.kernel.org/pub/scm/git/git.git cd git git checkout -b new v1.5.2 make make install
The tutorials lie if you use 1.4.x!
Set up your own project.
~/src$ cd myproject [trim unwanted, generated files] ~/src/myproject git init ~/src/myproject git add . ~/src/myproject git commit -m "Initial import of my project" [Digression on $EDITOR variable]
Make your repo available to outsiders.
How to do this?
If git is available in the web server:
ssh www.example.com cd public_html mkdir git cd git mkdir myproject.git GIT_DIR=myproject.git git-init-db touch myproject.git/git-daemon-export-ok emacs myproject.git/description chmod +x myproject.git/hooks/post-update
If you just want to push your master branch:
git push ssh://www.example.com/~username/public_html/git/myproject.git master
(or substitute "master" for the branch you want to push. This will create a branch in the remote repository with the same name)
If you want to push a local branch with a different name in the remote:
git push ssh://www.example.com/~username/public_html/git/myproject.git localname:refs/heads/differentname
Elsewhere:
git clone http://www.example.com/~username/git/myproject.git
See below, "If you want something other than the remote "master" branch" if you want to work on a branch that the remote published, but that is not their master branch.
If git is not available on the web server:
git clone --bare . /tmp/myproject.git git --bare --git-dir=/tmp/myproject.git update-server-info chmod +x /tmp/myproject.git/hooks/post-update scp -r /tmp/myproject.git www.example.com:~/public_html/git/
Make a branch:
git checkout -b mybranch
If you want something other than the remote "master" branch:
git clone http://www.example.com/~username/git/repo-name cd repo-name git fetch git checkout --track -b mybranch origin/remote-branch-name
With this, "git pull" will automatically fetch and merge changes from the remote branch. If you don't use --track, "git pull" will just fetch the changes into the mirror of the remote branch (origin/remote-branch-name), but not merge them into your working copy.
Once you are done with your changes, prepare a patch set:
git-format-patch master -> will spit one of 00xx-blahblah.patch for every commit
Preparing an easily-readable patch set:
git-format-patch will give you sequential patches based on your commits, but this is not always ideal since you were experimenting.
Create a new branch, "prepare-for-upstream"
How to cherry-pick everything into your new branch?
- git-format-patch in the original branch
- Apply the patches by hand (ugh!)
- Commit in order
- (13:03:50) gitte: federico1: did you try git-gui? (13:04:19) gitte: federico1: I would do this: "git cherry-pick -n <commit>; git gui".
How to ensure that in the end the new branch has all the patches from your original branch?
- Just a git-diff or manual diff?
Upstream can then do this:
git checkout -b merge-johnnys-changes git pull git://johnny.com/git/project johnnys-branchname <check that everything is okay> git checkout master git merge merge-johnnys-changes
http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#the-workflow
http://www.freedesktop.org/wiki/Infrastructure/git/RepositoryAdmin
http://www.kernel.org/pub/software/scm/git/docs/howto/setup-git-server-over-http.txt Git over http, plenty of configuration needed in Apache.
Good practices: keep your work repo in your laptop; keep a public repo in another server which will also function as your backup (laptop's hard drive crashes!).
git add --interactive (prompts for which hunks to apply).
git rebase --interactive -
http://blog.madism.org/index.php/2007/09/09/138-git-awsome-ness-git-rebase-interactive
View all branches: gitk --all
Subversion:
Get a whole SVN repo:
git-svn clone svn+ssh://user@svn.gnome.org/svn/project/trunk
Now you can "git commit" locally, examine history, etc.
If you do a merge from a local branch, do it like
git checkout master git merge --squash my-work-branch
See this for info:
Finally Commit your changes to SVN upstream:
git-svn dcommit
Update from SVN periodially:
git-svn rebase
- cherry-pick:
(12:56:21 PM) federico: robtaylor: how do you use cherry-pick? (12:57:05 PM) robtaylor: federico: git log <dev branch>, get patch id, git-cherry-pick -n patchid (12:57:09 PM) robtaylor: repeat (12:57:15 PM) robtaylor: git commit
Incorrect / incomplete / inconsistent / ambiguous docs:
http://www.freedesktop.org/wiki/Infrastructure/git/Users - section "Checking out a repository" mentions "git checkout branchname", but that won't give you a remote branch.
http://www.freedesktop.org/wiki/Infrastructure/git/Developers in the section "Working on branches" mentions how to edit your .git/remotes/origin (doesn't exist by default! should the user just create it?). It mentions adding a bunch of stuff to that file so that you can push/pull easily.
http://www.freedesktop.org/wiki/Infrastructure/git/RepositoryAdmin in the section "Personal repositories" suggests "git push --force --all URL". Why do we need --force --all to get started?
git pull origin branchname:branchname "Pull from the origin, from their branchname, into my branchname" - otherwise it will pull from the origin's master. (see http://www.freedesktop.org/wiki/Infrastructure/git/Users)
Tidbits:
"When you diff, commit, etc. code, you are doing it against your local repository. Clone, pull, and push are used to move changes between repositories." - from http://www.freedesktop.org/wiki/Infrastructure/git/Developers
http://www.freedesktop.org/wiki/Infrastructure/git/Developers mentions "Getting the latest upstream code", and the difference between "git pull" (does fetch-and-merge, useful when you haven't made changes), and "git fetch / git rebase" (useful when you have made changes, so your commit history doesn't get a merge in the middle).
http://www.freedesktop.org/wiki/Infrastructure/git/UIFlaws --- really nice collection of stupidities in git's UI.
Nice things about Git:
- Setting up a mediawiki, patching it with funny extensions.
- Create a git repo right there - no "import", no "re-checkout", etc.
- Extension requires patches - patch, small-commit.
- My own fixes - small fix, commit.
