Read the git tutorial. You need to at least set up your config variables.
Install git on Darwin
Install fink, use unstable sources.
Git package in Fink
Install on Debian
apt-get install git-core
Tracking WebKit git and our patches against it
How the WebKit mirror was constructed:
mkdir /srv/git/webkit cd /srv/git/webkit nox:/srv/git/webkit% git --bare init --shared nox:/srv/git/webkit% git --bare fetch git://git.webkit.org/WebKit.git master:master git fetch -f git://git.webkit.org/WebKit.git master:master # and again later forcing updates touch git-daemon-export-ok echo ssh://git.webvm.net/srv/git/$(basename `pwd`) > cloneurl
This could be wrong. Maybe I should have:
git remote add webkit git://git.webkit.org/WebKit.git git fetch webkit
I posted to the git mailing list to ensure I am doing this right (I am). Unfortunately when you work on a WebKit branch you need make a complete checkout. You really can’t get around that.
gitweb.cgi configuration for public and private repos
/var/cache/git has been split out into
nox:~% cat /srv/www/git.webvm.net/.htaccess SetEnv GITWEB_CONFIG /srv/www/git.webvm.net/gitweb.conf nox:~% egrep 'projectroot =' /srv/www/git.webvm.net/gitweb.conf $projectroot = "/var/cache/git/public"; nox:~% egrep 'projectroot =' /srv/www/g.webvm.net/gitweb.conf $projectroot = "/var/cache/git/private";
Setting up projects to be public:
nox:/var/cache/git/public% sudo ln -s /srv/git/backup nox:/var/cache/git/public% sudo ln -s /srv/git/runtest
Developer working cycle
Use case: We are working with directfb code base. We need a central location to manage our changes.
The ssh:// URL can be found from the web interface.
As a developer using the code base of an opensource project, you will want to a
seperate branch with:
git-checkout -b $BRANCHNAME. Could I please suggest
calling $BRANCHNAME you want people to look at as $USER, though perhaps naming
$BRANCHNAME as a particular feature is wiser.
Create as many branches as you like, though to let people see your work, you
need to push back with
git push origin $BRANCHNAME.
Converting from Subversion to Git
- Create the git repo on example.com
git --bare init --sharedin a dir called ‘/srv/git/oldsvn’
git-svn clone $SVN_URL# svn checkout your subversion repo you want to migrate to git
git push ssh://example.com/srv/git/oldsvn --all
Pushing sources to a newly created git repository
git init git add . git commit -a -m "initial" git-config remote.origin.url ssh://git.webvm.net/srv/git/runtest git push --all
Git has a bit of a steep learning curve. Please add you findings below:
Q: how do i get the last commit id (current version), without say using
git log --pretty=oneline | head -n1?
Q: How do I see all branches?
Q: What does a git-pull do?
A: It is a
git fetch origin and then a
git merge origin
Q: How do I find out what’s new before I do a pull?
- git fetch origin
- git log master..origin/master
Q: How do I quickly clean up untracked (e.g. build residue) files?
git clean -d
Q: How do I make a remote branch local?
git branch -a # to find name of $remote git checkout -b $remote origin/$remote
Q: “git diff 08762e852c49709a22ef8fd9c82bb6a6b28ed91b” is not showing the same as http://....git;a=commitdiff;h=08762e852c49709a22ef8fd9c82bb6a6b28ed91b
git show 08762e852c49709a22ef8fd9c82bb6a6b28ed91b
Q: Oops! I accidentally added private/personal/health.txt
git rm -f --cached private/personal/health.txt
Q: How do I correct a bad commit log?
git commit --amend
Q: How do I configure
git commit to be more like
With git, commiting changes should require a
git add file and then a
git commit. Most people get around this boring default behaviour by issuing
git commit -a all the time. But if you can’t be bothered to type in a “-a” switch
all the time, create an alias with in your ~/.gitconfig, like so:
git config --global alias.ci 'commit -a'
Then svn style
svn ci should work for committing:
Q: What’s the difference between master and head?
- origin/HEAD is whatever branch is checked out in the repo you cloned from
- origin/master is the master branch in the repo you cloned from
- so HEAD could point to master, or it could point to branchsomethingelse
- in practice HEAD almost always points to master
Q: Oh no I have loads of conflicts to manage! HELP?!
git-mergetool -t vimdiff
It’s a bit scary. Try understand how everything works in a test repo…
git init in /tmp/foo and go from there.
Q: Can I get git to work with CVS?
See this Git CVS workflow tutorial.
Q: How do I
svn revert a single file “platform.html”?
git checkout platform.html
Q: How do I unadd a file?
To see the paths:
Notice the odd ‘–’
x61:~% git reset -- code/trunk/tests/html/logs/index.cgi
git rm --cached aplix/code/trunk/tests/html/602/index.html
Q: How do I wipe the history of a git repo ? (you probably don’t want to do this!)
rm -fr .git git init
Q: How do I do a colour diff between two files ‘foo’ and ‘bar’ that aren’t in git?
git diff --color-words --no-index foo bar