Junio C Hamano | 91f77a0 | 2007-01-12 02:43:42 | [diff] [blame] | 1 | git-init(1) |
| 2 | =========== |
| 3 | |
| 4 | NAME |
| 5 | ---- |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 6 | git-init - Create an empty Git repository or reinitialize an existing one |
Junio C Hamano | 91f77a0 | 2007-01-12 02:43:42 | [diff] [blame] | 7 | |
| 8 | |
| 9 | SYNOPSIS |
| 10 | -------- |
Junio C Hamano | 15567bc | 2011-07-23 00:51:59 | [diff] [blame] | 11 | [verse] |
Junio C Hamano | a03ac86 | 2011-04-02 04:32:29 | [diff] [blame] | 12 | 'git init' [-q | --quiet] [--bare] [--template=<template_directory>] |
Junio C Hamano | f93530e | 2011-05-25 23:59:59 | [diff] [blame] | 13 | [--separate-git-dir <git dir>] |
Junio C Hamano | a03ac86 | 2011-04-02 04:32:29 | [diff] [blame] | 14 | [--shared[=<permissions>]] [directory] |
Junio C Hamano | 91f77a0 | 2007-01-12 02:43:42 | [diff] [blame] | 15 | |
| 16 | |
Junio C Hamano | a03ac86 | 2011-04-02 04:32:29 | [diff] [blame] | 17 | DESCRIPTION |
| 18 | ----------- |
| 19 | |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 20 | This command creates an empty Git repository - basically a `.git` |
Junio C Hamano | a03ac86 | 2011-04-02 04:32:29 | [diff] [blame] | 21 | directory with subdirectories for `objects`, `refs/heads`, |
| 22 | `refs/tags`, and template files. An initial `HEAD` file that |
| 23 | references the HEAD of the master branch is also created. |
| 24 | |
| 25 | If the `$GIT_DIR` environment variable is set then it specifies a path |
| 26 | to use instead of `./.git` for the base of the repository. |
| 27 | |
| 28 | If the object storage directory is specified via the |
| 29 | `$GIT_OBJECT_DIRECTORY` environment variable then the sha1 directories |
| 30 | are created underneath - otherwise the default `$GIT_DIR/objects` |
| 31 | directory is used. |
| 32 | |
| 33 | Running 'git init' in an existing repository is safe. It will not |
| 34 | overwrite things that are already there. The primary reason for |
| 35 | rerunning 'git init' is to pick up newly added templates (or to move |
| 36 | the repository to another place if --separate-git-dir is given). |
| 37 | |
Junio C Hamano | 91f77a0 | 2007-01-12 02:43:42 | [diff] [blame] | 38 | OPTIONS |
| 39 | ------- |
| 40 | |
| 41 | -- |
| 42 | |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 43 | -q:: |
| 44 | --quiet:: |
Junio C Hamano | 1d90cb0 | 2007-07-03 07:05:31 | [diff] [blame] | 45 | |
| 46 | Only print error and warning messages, all other output will be suppressed. |
| 47 | |
Junio C Hamano | 9e1793f | 2008-06-02 07:31:16 | [diff] [blame] | 48 | --bare:: |
| 49 | |
| 50 | Create a bare repository. If GIT_DIR environment is not set, it is set to the |
| 51 | current working directory. |
| 52 | |
Junio C Hamano | 91f77a0 | 2007-01-12 02:43:42 | [diff] [blame] | 53 | --template=<template_directory>:: |
| 54 | |
Junio C Hamano | caa712a | 2010-03-11 01:17:35 | [diff] [blame] | 55 | Specify the directory from which templates will be used. (See the "TEMPLATE |
| 56 | DIRECTORY" section below.) |
Junio C Hamano | 91f77a0 | 2007-01-12 02:43:42 | [diff] [blame] | 57 | |
Junio C Hamano | a03ac86 | 2011-04-02 04:32:29 | [diff] [blame] | 58 | --separate-git-dir=<git dir>:: |
| 59 | |
| 60 | Instead of initializing the repository where it is supposed to be, |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 61 | place a filesytem-agnostic Git symbolic link there, pointing to the |
| 62 | specified path, and initialize a Git repository at the path. The |
| 63 | result is Git repository can be separated from working tree. If this |
Junio C Hamano | a03ac86 | 2011-04-02 04:32:29 | [diff] [blame] | 64 | is reinitialization, the repository will be moved to the specified |
| 65 | path. |
| 66 | |
Junio C Hamano | d2179ef | 2010-10-22 04:12:17 | [diff] [blame] | 67 | --shared[=(false|true|umask|group|all|world|everybody|0xxx)]:: |
Junio C Hamano | 91f77a0 | 2007-01-12 02:43:42 | [diff] [blame] | 68 | |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 69 | Specify that the Git repository is to be shared amongst several users. This |
Junio C Hamano | 91f77a0 | 2007-01-12 02:43:42 | [diff] [blame] | 70 | allows users belonging to the same group to push into that |
| 71 | repository. When specified, the config variable "core.sharedRepository" is |
| 72 | set so that files and directories under `$GIT_DIR` are created with the |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 73 | requested permissions. When not specified, Git will use permissions reported |
Junio C Hamano | 91f77a0 | 2007-01-12 02:43:42 | [diff] [blame] | 74 | by umask(2). |
| 75 | |
| 76 | The option can have the following values, defaulting to 'group' if no value |
| 77 | is given: |
| 78 | |
| 79 | - 'umask' (or 'false'): Use permissions reported by umask(2). The default, |
| 80 | when `--shared` is not specified. |
| 81 | |
| 82 | - 'group' (or 'true'): Make the repository group-writable, (and g+sx, since |
| 83 | the git group may be not the primary group of all users). |
Junio C Hamano | 83eded1 | 2009-04-20 08:18:00 | [diff] [blame] | 84 | This is used to loosen the permissions of an otherwise safe umask(2) value. |
| 85 | Note that the umask still applies to the other permission bits (e.g. if |
| 86 | umask is '0022', using 'group' will not remove read privileges from other |
| 87 | (non-group) users). See '0xxx' for how to exactly specify the repository |
| 88 | permissions. |
Junio C Hamano | 91f77a0 | 2007-01-12 02:43:42 | [diff] [blame] | 89 | |
| 90 | - 'all' (or 'world' or 'everybody'): Same as 'group', but make the repository |
| 91 | readable by all users. |
| 92 | |
Junio C Hamano | 83eded1 | 2009-04-20 08:18:00 | [diff] [blame] | 93 | - '0xxx': '0xxx' is an octal number and each file will have mode '0xxx'. |
| 94 | '0xxx' will override users' umask(2) value (and not only loosen permissions |
| 95 | as 'group' and 'all' does). '0640' will create a repository which is |
| 96 | group-readable, but not group-writable or accessible to others. '0660' will |
| 97 | create a repo that is readable and writable to the current user and group, |
| 98 | but inaccessible to others. |
Junio C Hamano | 2f102bb | 2008-04-26 02:23:37 | [diff] [blame] | 99 | |
Junio C Hamano | fe98605 | 2007-12-19 07:33:38 | [diff] [blame] | 100 | By default, the configuration flag receive.denyNonFastForwards is enabled |
Junio C Hamano | 91f77a0 | 2007-01-12 02:43:42 | [diff] [blame] | 101 | in shared repositories, so that you cannot force a non fast-forwarding push |
| 102 | into it. |
| 103 | |
Junio C Hamano | fd9274d | 2009-08-05 21:21:39 | [diff] [blame] | 104 | If you name a (possibly non-existent) directory at the end of the command |
| 105 | line, the command is run inside the directory (possibly after creating it). |
| 106 | |
Junio C Hamano | 91f77a0 | 2007-01-12 02:43:42 | [diff] [blame] | 107 | -- |
| 108 | |
| 109 | |
Junio C Hamano | caa712a | 2010-03-11 01:17:35 | [diff] [blame] | 110 | TEMPLATE DIRECTORY |
| 111 | ------------------ |
| 112 | |
| 113 | The template directory contains files and directories that will be copied to |
| 114 | the `$GIT_DIR` after it is created. |
| 115 | |
| 116 | The template directory used will (in order): |
| 117 | |
| 118 | - The argument given with the `--template` option. |
| 119 | |
| 120 | - The contents of the `$GIT_TEMPLATE_DIR` environment variable. |
| 121 | |
| 122 | - The `init.templatedir` configuration variable. |
| 123 | |
| 124 | - The default template directory: `/usr/share/git-core/templates`. |
| 125 | |
| 126 | The default template directory includes some directory structure, some |
| 127 | suggested "exclude patterns", and copies of sample "hook" files. |
| 128 | The suggested patterns and hook files are all modifiable and extensible. |
Junio C Hamano | 91f77a0 | 2007-01-12 02:43:42 | [diff] [blame] | 129 | |
| 130 | EXAMPLES |
| 131 | -------- |
| 132 | |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 133 | Start a new Git repository for an existing code base:: |
Junio C Hamano | 91f77a0 | 2007-01-12 02:43:42 | [diff] [blame] | 134 | + |
| 135 | ---------------- |
| 136 | $ cd /path/to/my/codebase |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 137 | $ git init <1> |
| 138 | $ git add . <2> |
Junio C Hamano | 91f77a0 | 2007-01-12 02:43:42 | [diff] [blame] | 139 | ---------------- |
| 140 | + |
| 141 | <1> prepare /path/to/my/codebase/.git directory |
| 142 | <2> add all existing file to the index |
| 143 | |
Junio C Hamano | 91f77a0 | 2007-01-12 02:43:42 | [diff] [blame] | 144 | GIT |
| 145 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 146 | Part of the linkgit:git[1] suite |