This is an old revision of the document!
Overview
Basic operation of creating a new repo or enhancing an existing repo with git init.
Default content of new .git directory
New content consists of combination of:
- auto-generated content
- content copied from some template directory
.
├── branches
├── config
├── description
├── HEAD
├── hooks
│ ├── applypatch-msg.sample
│ ├── commit-msg.sample
│ ├── fsmonitor-watchman.sample
│ ├── post-update.sample
│ ├── pre-applypatch.sample
│ ├── pre-commit.sample
│ ├── prepare-commit-msg.sample
│ ├── pre-push.sample
│ ├── pre-rebase.sample
│ ├── pre-receive.sample
│ └── update.sample
├── info
│ └── exclude
├── objects
│ ├── info
│ └── pack
└── refs
├── heads
└── tags
Running "git init" in an existing repository
Running git init in an existing repository is safe. It will not overwrite things that are already there. The primary reason for rerunning git init is to pick up newly added templates (or to move the repository to another place if --separate-git-dir is given).
Working with the template directory
By default, git init will populate your new .git directory with the contents of /usr/share/git-core/templates/, without overwriting existing content of the same name:
├── branches
├── description
├── hooks
│ ├── applypatch-msg.sample
│ ├── commit-msg.sample
│ ├── fsmonitor-watchman.sample
│ ├── post-update.sample
│ ├── pre-applypatch.sample
│ ├── pre-commit.sample
│ ├── prepare-commit-msg.sample
│ ├── pre-push.sample
│ ├── pre-rebase.sample
│ ├── pre-receive.sample
│ └── update.sample
└── info
└── exclude
You have the option of selecting a different template directory when you run git init:
TEMPLATE DIRECTORY
Files and directories in the template directory whose name do
not start with a dot will be copied to the $GIT_DIR after it is
created.
The template directory will be one of the following (in order):
· the argument given with the --template option;
· the contents of the $GIT_TEMPLATE_DIR environment variable;
· the init.templateDir configuration variable; or
· the default template directory:
/usr/share/git-core/templates.
The default template directory includes some directory
structure, suggested "exclude patterns" (see gitignore(5)), and
sample hook files.
The sample hooks are all disabled by default, To enable one of
the sample hooks rename it by removing its .sample suffix.