@@ -6,21 +6,24 @@ use the [v3.x branch](https://github.com/kubernetes/git-sync/tree/release-3.x).
6
6
7
7
# git-sync
8
8
9
- git-sync is a simple command that pulls a git repository into a local directory.
10
- It is a perfect "sidecar" container in Kubernetes - it can periodically pull
11
- files down from a repository so that an application can consume them.
9
+ git-sync is a simple command that pulls a git repository into a local
10
+ directory, waits for a while, then repeats. As the remote repository chan ges,
11
+ those changes will be synced locally. It is a perfect "sidecar" container in
12
+ Kubernetes - it can pull files down from a repository so that an application
13
+ can consume them.
12
14
13
15
git-sync can pull one time, or on a regular interval. It can pull from the
14
16
HEAD of a branch, from a git tag, or from a specific git hash. It will only
15
- re-pull if the target of the run has changed in the upstream repository. When
16
- it re-pulls, it updates the destination directory atomically. In order to do
17
- this, it uses a git worktree in a subdirectory of the ` --root ` and flips a
18
- symlink .
17
+ re-pull if the referenced target has changed in the upstream repository (e.g. a
18
+ new commit on a branch). It "publishes" each sync through a worktree and a
19
+ named symlink. This ensures an atomic update - consumers will not see a
20
+ partially constructed view of the local repository .
19
21
20
22
git-sync can pull over HTTP(S) (with authentication or not) or SSH.
21
23
22
- git-sync can also be configured to make a webhook call upon successful git repo
23
- synchronization. The call is made after the symlink is updated.
24
+ git-sync can also be configured to make a webhook call or exec a command upon
25
+ successful git repo synchronization. The call is made after the symlink is
26
+ updated.
24
27
25
28
## Major update: v3.x -> v4.x
26
29
@@ -75,23 +78,36 @@ docker run -d \
75
78
nginx
76
79
```
77
80
81
+ ### Flags
82
+
83
+ git-sync has many flags and optional features (see the manual below). Most of
84
+ those flags can be configured through environment variables, but in most cases
85
+ (with the obvious exception of passwords) flags are preferred, because the
86
+ program can abort if an invalid flag is specified, but a misspelled environment
87
+ variable will just be ignored. We've tried to stay backwards-compatible across
88
+ major versions (by accepting deprecated flags and environment variables), but
89
+ some things have evolved, and users are encouraged to use the most recent flags
90
+ for their major verion.
91
+
78
92
### Volumes
79
93
80
94
The ` --root ` flag must indicate either a directory that either a) does not
81
95
exist (it will be created); or b) exists and is empty; or c) can be emptied by
82
96
removing all of the contents.
83
97
84
- Why? Git demands to clone into an empty directory. If the directory exists
85
- and is not empty, git-sync will try to empty it by removing everything in it
86
- (we can't just ` rm -rf ` the dir because it might be a mounted volume). If that
87
- fails, git-sync will abort.
98
+ Why? Git really wants an empty directory, to avoid any confusion . If the
99
+ directory exists and is not empty, git-sync will try to empty it by removing
100
+ everything in it (we can't just ` rm -rf ` the dir because it might be a mounted
101
+ volume). If that fails, git-sync will abort.
88
102
89
103
With the above example or with a Kubernetes ` emptyDir ` , there is usually no
90
104
problem. The problematic case is when the volume is the root of a filesystem,
91
105
which sometimes contains metadata (e.g. ext{2,3,4} have a ` lost+found ` dir).
92
- Git will not clone into such a directory (`fatal: destination path
93
- '/tmp/git-data' already exists and is not an empty directory`). The only real
94
- solution is to use a sub-directory of the volume as the ` --root ` .
106
+ The only real solution is to use a sub-directory of the volume as the ` --root ` .
107
+
108
+ ## More docs
109
+
110
+ More documentation on specific topics can be [ found here] ( ./docs ) .
95
111
96
112
## Manual
97
113
102
118
git-sync - sync a remote git repository
103
119
104
120
SYNOPSIS
105
- git-sync --repo=<repo> [OPTION ]...
121
+ git-sync --repo=<repo> --root=<path> [OPTIONS ]...
106
122
107
123
DESCRIPTION
108
124
@@ -128,7 +144,8 @@ DESCRIPTION
128
144
OPTIONS
129
145
130
146
Many options can be specified as either a commandline flag or an environment
131
- variable.
147
+ variable, but flags are preferred because a misspelled flag is a fatal
148
+ error while a misspelled environment variable is silently ignored.
132
149
133
150
--add-user, $GITSYNC_ADD_USER
134
151
Add a record to /etc/passwd for the current UID/GID. This is
@@ -140,9 +157,6 @@ OPTIONS
140
157
(200) and produce a series of key=value lines, including
141
158
"username=<value>" and "password=<value>".
142
159
143
- --change-permissions <int>, $GITSYNC_PERMISSIONS
144
- Change permissions on the checked-out files to the specified mode.
145
-
146
160
--cookie-file <string>, $GITSYNC_COOKIE_FILE
147
161
Use a git cookiefile (/etc/git-secret/cookie_file) for
148
162
authentication.
@@ -165,8 +179,8 @@ OPTIONS
165
179
--exechook-command <string>, $GITSYNC_EXECHOOK_COMMAND
166
180
An optional command to be executed after syncing a new hash of the
167
181
remote repository. This command does not take any arguments and
168
- executes with the synced repo as its working directory. The
169
- environment variable $GITSYNC_HASH will be set to the git hash that
182
+ executes with the synced repo as its working directory. The following
183
+ environment variables $GITSYNC_HASH will be set to the git hash that
170
184
was synced. The execution is subject to the overall --sync-timeout
171
185
flag and will extend the effective period between sync attempts.
172
186
This flag obsoletes --sync-hook-command, but if sync-hook-command
@@ -211,6 +225,13 @@ OPTIONS
211
225
- off: Disable explicit git garbage collection, which may be a good
212
226
fit when also using --one-time.
213
227
228
+ --group-write, $GITSYNC_GROUP_WRITE
229
+ Ensure that data written to disk (including the git repo metadata,
230
+ checked out files, worktrees, and symlink) are all group writable.
231
+ This corresponds to git's notion of a "shared repository". This is
232
+ useful in cases where data produced by git-sync is used by a
233
+ different UID. This replaces the older --change-permissions flag.
234
+
214
235
-h, --help
215
236
Print help text and exit.
216
237
0 commit comments