Information Technology Reference
In-Depth Information
$ cd git-recipes
$ mkdir 10-12
$ cd 10-12
Initialize johns-repository with:
# commands issued in git-recipes/10-12 directory
$ git init johns-repo
$ cd johns-repo
$ git simple-commit "Initial commit"
Next, clone
johns-repo
to get
public-repo
:
# command issued in git-recipes/10-12 directory
$ git clone johns-repo public-repo
To allow pushes into
public-repo
, which is a non-bare repository, change its
configuration with:
# command issued in public-repo directory
$ git config receive.denyCurrentBranch ignore
$ git config core.worktree ../
Then rename the file
public-repo/.git/hooks/post-update.sample
to
public-repo/.git/hooks/post-update
. You can do this with:
# command issued in public-repo directory
$ mv .git/hooks/post-update.sample .git/hooks/post-update
Change the contents of
public-repo/.git/hooks/post-update
as shown
in
Listing 10-4
.
Listing 10-4.
The contents of public-repo/.git/hooks/post-update
#!/bin/sh
exec git reset --hard
The configuration of
public-repo
is finished. Now go to
johns-repo
and add
the remote: