git.txt 14.0 KB
Newer Older
1
git(7)
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
======

NAME
----
git - the stupid content tracker


SYNOPSIS
--------
'git-<command>' <args>

DESCRIPTION
-----------

This is reference information for the core git commands.

18 19 20
Before reading this cover to cover, you may want to take a look
at the link:tutorial.html[tutorial] document.

J
Junio C Hamano 已提交
21
The <<Discussion>> section below contains much useful definition and
22
clarification info - read that first.  And of the commands, I suggest
23 24
reading gitlink:git-update-index[1] and
gitlink:git-read-tree[1] first - I wish I had!
25

J
Junio C Hamano 已提交
26 27 28
If you are migrating from CVS, link:cvs-migration.html[cvs migration]
document may be helpful after you finish the tutorial.

29 30 31 32 33
After you get the general feel from the tutorial and this
overview page, you may want to take a look at the
link:howto-index.html[howto] documents.


34 35 36 37 38 39 40 41 42
David Greaves <david@dgreaves.com>
08/05/05

Updated by Junio C Hamano <junkio@cox.net> on 2005-05-05 to
reflect recent changes.

Commands Overview
-----------------
The git commands can helpfully be split into those that manipulate
43 44 45
the repository, the cache and the working fileset, those that
interrogate and compare them, and those that moves objects and
references between repositories.
46

J
Junio C Hamano 已提交
47 48 49 50
In addition, git itself comes with a spartan set of porcelain
commands.  They are usable but are not meant to compete with real
Porcelains.

51
There are also some ancillary programs that can be viewed as useful
52 53 54
aids for using the core commands but which are unlikely to be used by
SCMs layered over git.

55 56
Manipulation commands
~~~~~~~~~~~~~~~~~~~~~
57
gitlink:git-apply[1]::
58 59 60
	Reads a "diff -up1" or git generated patch file and
	applies it to the working tree.

61
gitlink:git-checkout-index[1]::
62
	Copy files from the cache to the working directory
J
Junio C Hamano 已提交
63
	Previously this command was known as git-checkout-cache.
64

65
gitlink:git-commit-tree[1]::
66 67
	Creates a new commit object

68
gitlink:git-hash-object[1]::
69 70
	Computes the object ID from a file.

71
gitlink:git-init-db[1]::
72 73
	Creates an empty git object database

74
gitlink:git-merge-index[1]::
75
	Runs a merge for files needing merging
J
Junio C Hamano 已提交
76
	Previously this command was known as git-merge-cache.
77

78
gitlink:git-mktag[1]::
79 80
	Creates a tag object

81
gitlink:git-pack-objects[1]::
82 83
	Creates a packed archive of objects.

84
gitlink:git-prune-packed[1]::
85 86
	Remove extra objects that are already in pack files.

87
gitlink:git-read-tree[1]::
88 89
	Reads tree information into the directory cache

90
gitlink:git-unpack-objects[1]::
91 92
	Unpacks objects out of a packed archive.

93
gitlink:git-update-index[1]::
94
	Modifies the index or directory cache
J
Junio C Hamano 已提交
95
	Previously this command was known as git-update-cache.
96

97
gitlink:git-write-tree[1]::
98 99
	Creates a tree from the current cache

100

101 102
Interrogation commands
~~~~~~~~~~~~~~~~~~~~~~
103

104
gitlink:git-cat-file[1]::
105 106
	Provide content or type information for repository objects

107
gitlink:git-diff-index[1]::
108
	Compares content and mode of blobs between the cache and repository
J
Junio C Hamano 已提交
109
	Previously this command was known as git-diff-cache.
110

111
gitlink:git-diff-files[1]::
112 113
	Compares files in the working tree and the cache

114
gitlink:git-diff-stages[1]::
115 116
	Compares two "merge stages" in the index file.

117
gitlink:git-diff-tree[1]::
118 119
	Compares the content and mode of blobs found via two tree objects

120
gitlink:git-fsck-objects[1]::
121
	Verifies the connectivity and validity of the objects in the database
J
Junio C Hamano 已提交
122
	Previously this command was known as git-fsck-cache.
123

124
gitlink:git-ls-files[1]::
125 126
	Information about files in the cache/working directory

127
gitlink:git-ls-tree[1]::
128 129
	Displays a tree object in human readable form

130
gitlink:git-merge-base[1]::
131
	Finds as good a common ancestor as possible for a merge
132

133
gitlink:git-rev-list[1]::
134 135
	Lists commit objects in reverse chronological order

136
gitlink:git-show-index[1]::
137 138
	Displays contents of a pack idx file.

139
gitlink:git-tar-tree[1]::
140 141
	Creates a tar archive of the files in the named tree

142
gitlink:git-unpack-file[1]::
143 144
	Creates a temporary file with a blob's contents

145
gitlink:git-var[1]::
146 147
	Displays a git logical variable

148
gitlink:git-verify-pack[1]::
149 150
	Validates packed GIT archive files

151 152 153 154
The interrogate commands may create files - and you can force them to
touch the working file set - but in general they don't


155 156 157
Synching repositories
~~~~~~~~~~~~~~~~~~~~~

158
gitlink:git-clone-pack[1]::
159 160 161
	Clones a repository into the current repository (engine
	for ssh and local transport)

162
gitlink:git-fetch-pack[1]::
163 164
	Updates from a remote repository.

165
gitlink:git-http-fetch[1]::
166
	Downloads a remote GIT repository via HTTP
J
Junio C Hamano 已提交
167
	Previously this command was known as git-http-pull.
168

169
gitlink:git-local-fetch[1]::
170
	Duplicates another GIT repository on a local system
J
Junio C Hamano 已提交
171
	Previously this command was known as git-local-pull.
172

173
gitlink:git-peek-remote[1]::
174
	Lists references on a remote repository using upload-pack protocol.
175

176
gitlink:git-receive-pack[1]::
177 178
	Invoked by 'git-send-pack' to receive what is pushed to it.

179
gitlink:git-send-pack[1]::
180
	Pushes to a remote repository, intelligently.
181

182
gitlink:git-ssh-fetch[1]::
183
	Pulls from a remote repository over ssh connection
J
Junio C Hamano 已提交
184
	Previously this command was known as git-ssh-pull.
185

186
gitlink:git-ssh-upload[1]::
J
Junio C Hamano 已提交
187 188
	Helper "server-side" program used by git-ssh-fetch
	Previously this command was known as git-ssh-push.
189

190
gitlink:git-update-server-info[1]::
191 192 193
	Updates auxiliary information on a dumb server to help
	clients discover references and packs on it.

194
gitlink:git-upload-pack[1]::
195 196 197
	Invoked by 'git-clone-pack' and 'git-fetch-pack' to push
	what are asked for.

198

J
Junio C Hamano 已提交
199 200
Porcelain-ish Commands
----------------------
201

202
gitlink:git-add[1]::
203
	Add paths to the index file.
J
Junio C Hamano 已提交
204
	Previously this command was known as git-add-script.
205

206
gitlink:git-applymbox[1]::
207 208
	Apply patches from a mailbox.

209
gitlink:git-bisect[1]::
210
	Find the change that introduced a bug.
J
Junio C Hamano 已提交
211
	Previously this command was known as git-bisect-script.
212

213
gitlink:git-branch[1]::
214
	Create and Show branches.
J
Junio C Hamano 已提交
215
	Previously this command was known as git-branch-script.
216

217
gitlink:git-checkout[1]::
J
Junio C Hamano 已提交
218
	Checkout and switch to a branch.
J
Junio C Hamano 已提交
219
	Previously this command was known as git-checkout-script.
J
Junio C Hamano 已提交
220

221
gitlink:git-cherry-pick[1]::
222
	Cherry-pick the effect of an existing commit.
J
Junio C Hamano 已提交
223
	Previously this command was known as git-cherry-pick-script.
J
Junio C Hamano 已提交
224

225
gitlink:git-clone[1]::
226
	Clones a repository into a new directory.
J
Junio C Hamano 已提交
227
	Previously this command was known as git-clone-script.
J
Junio C Hamano 已提交
228

229
gitlink:git-commit[1]::
230
	Record changes to the repository.
J
Junio C Hamano 已提交
231
	Previously this command was known as git-commit-script.
J
Junio C Hamano 已提交
232

233
gitlink:git-diff[1]::
234
	Show changes between commits, commit and working tree, etc.
J
Junio C Hamano 已提交
235 236
	Previously this command was known as git-diff-script.

237
gitlink:git-fetch[1]::
J
Junio C Hamano 已提交
238
	Download from a remote repository via various protocols.
J
Junio C Hamano 已提交
239
	Previously this command was known as git-fetch-script.
J
Junio C Hamano 已提交
240

241
gitlink:git-format-patch[1]::
242
	Prepare patches for e-mail submission.
J
Junio C Hamano 已提交
243 244
	Previously this command was known as git-format-patch-script.

245
gitlink:git-grep[1]::
246 247
	Print lines matching a pattern

248
gitlink:git-log[1]::
249
	Shows commit logs.
J
Junio C Hamano 已提交
250
	Previously this command was known as git-log-script.
J
Junio C Hamano 已提交
251

252
gitlink:git-ls-remote[1]::
253
	Shows references in a remote or local repository.
J
Junio C Hamano 已提交
254
	Previously this command was known as git-ls-remote-script.
255

256
gitlink:git-merge[1]::
J
Junio C Hamano 已提交
257 258
	Grand unified merge driver.

259
gitlink:git-octopus[1]::
260
	Merge more than two commits.
J
Junio C Hamano 已提交
261
	Previously this command was known as git-octopus-script.
262

263
gitlink:git-pull[1]::
264
	Fetch from and merge with a remote repository.
J
Junio C Hamano 已提交
265
	Previously this command was known as git-pull-script.
266

267
gitlink:git-push[1]::
268
	Update remote refs along with associated objects.
J
Junio C Hamano 已提交
269
	Previously this command was known as git-push-script.
270

271
gitlink:git-rebase[1]::
272
	Rebase local commits to new upstream head.
J
Junio C Hamano 已提交
273
	Previously this command was known as git-rebase-script.
J
Junio C Hamano 已提交
274

275
gitlink:git-rename[1]::
276
	Rename files and directories.
J
Junio C Hamano 已提交
277
	Previously this command was known as git-rename-script.
J
Junio C Hamano 已提交
278

279
gitlink:git-repack[1]::
280
	Pack unpacked objects in a repository.
J
Junio C Hamano 已提交
281
	Previously this command was known as git-repack-script.
282

283
gitlink:git-reset[1]::
J
Junio C Hamano 已提交
284
	Reset current HEAD to the specified state.
J
Junio C Hamano 已提交
285
	Previously this command was known as git-reset-script.
J
Junio C Hamano 已提交
286

287
gitlink:git-resolve[1]::
288
	Merge two commits.
J
Junio C Hamano 已提交
289
	Previously this command was known as git-resolve-script.
290

291
gitlink:git-revert[1]::
292
	Revert an existing commit.
J
Junio C Hamano 已提交
293
	Previously this command was known as git-revert-script.
294

295
gitlink:git-shortlog[1]::
296 297
	Summarizes 'git log' output.

298
gitlink:git-show-branch[1]::
299 300
	Show branches and their commits.

301
gitlink:git-status[1]::
302
	Shows the working tree status.
J
Junio C Hamano 已提交
303
	Previously this command was known as git-status-script.
304

305
gitlink:git-verify-tag[1]::
306
	Check the GPG signature of tag.
J
Junio C Hamano 已提交
307
	Previously this command was known as git-verify-tag-script.
308

309
gitlink:git-whatchanged[1]::
310 311
	Shows commit logs and differences they introduce.

312

313 314
Ancillary Commands
------------------
315 316
Manipulators:

317
gitlink:git-applypatch[1]::
318
	Apply one patch extracted from an e-mail.
319

320
gitlink:git-archimport[1]::
J
Junio C Hamano 已提交
321
	Import an arch repository into git.
J
Junio C Hamano 已提交
322
	Previously this command was known as git-archimport-script.
J
Junio C Hamano 已提交
323

324
gitlink:git-convert-objects[1]::
325
	Converts old-style GIT repository
J
Junio C Hamano 已提交
326
	Previously this command was known as git-convert-cache.
327

328
gitlink:git-cvsimport[1]::
329
	Salvage your data out of another SCM people love to hate.
J
Junio C Hamano 已提交
330
	Previously this command was known as git-cvsimport-script.
331

332
gitlink:git-merge-one-file[1]::
J
Junio C Hamano 已提交
333 334
	The standard helper program to use with "git-merge-index"
	Previously this command was known as git-merge-one-file-script.
335

336
gitlink:git-prune[1]::
337
	Prunes all unreachable objects from the object database
J
Junio C Hamano 已提交
338
	Previously this command was known as git-prune-script.
339

340
gitlink:git-relink[1]::
341
	Hardlink common objects in local repositories.
J
Junio C Hamano 已提交
342
	Previously this command was known as git-relink-script.
343

344
gitlink:git-sh-setup[1]::
345
	Common git shell script setup code.
J
Junio C Hamano 已提交
346
	Previously this command was known as git-sh-setup-script.
347

348
gitlink:git-tag[1]::
349
	An example script to create a tag object signed with GPG
J
Junio C Hamano 已提交
350
	Previously this command was known as git-tag-script.
351 352


353
Interrogators:
354

355
gitlink:git-cherry[1]::
356
	Find commits not merged upstream.
357

358
gitlink:git-count-objects[1]::
359
	Count unpacked number of objects and their disk consumption.
J
Junio C Hamano 已提交
360
	Previously this command was known as git-count-objects-script.
361

362
gitlink:git-daemon[1]::
J
Junio C Hamano 已提交
363 364
	A really simple server for GIT repositories.

365
gitlink:git-get-tar-commit-id[1]::
J
Junio C Hamano 已提交
366 367
	Extract commit ID from an archive created using git-tar-tree.

368
gitlink:git-mailinfo[1]::
369 370
	Extracts patch from a single e-mail message.

371
gitlink:git-mailsplit[1]::
372 373
	git-mailsplit.

374
gitlink:git-patch-id[1]::
375
	Compute unique ID for a patch.
376

377
gitlink:git-parse-remote[1]::
J
Junio C Hamano 已提交
378
	Routines to help parsing $GIT_DIR/remotes/
J
Junio C Hamano 已提交
379
	Previously this command was known as git-parse-remote-script.
J
Junio C Hamano 已提交
380

381
gitlink:git-request-pull[1]::
J
Junio C Hamano 已提交
382 383
	git-request-pull.
	Previously this command was known as git-request-pull-script.
J
Junio C Hamano 已提交
384

385
gitlink:git-rev-parse[1]::
J
Junio C Hamano 已提交
386 387
	Pick out and massage parameters.

388
gitlink:git-send-email[1]::
389
	Send patch e-mails out of "format-patch --mbox" output.
J
Junio C Hamano 已提交
390
	Previously this command was known as git-send-email-script.
391

392
gitlink:git-stripspace[1]::
J
Junio C Hamano 已提交
393
	Filter out empty lines.
394 395


J
Junio C Hamano 已提交
396 397
Commands not yet documented
---------------------------
398

399
gitlink:gitk[1]::
400 401 402
	gitk.


403
Identifier Terminology
404 405
----------------------
<object>::
406
	Indicates the sha1 identifier for any type of object
407 408 409 410 411 412 413 414 415 416 417

<blob>::
	Indicates a blob object sha1 identifier

<tree>::
	Indicates a tree object sha1 identifier

<commit>::
	Indicates a commit object sha1 identifier

<tree-ish>::
418 419 420 421
	Indicates a tree, commit or tag object sha1 identifier.  A
	command that takes a <tree-ish> argument ultimately wants to
	operate on a <tree> object but automatically dereferences
	<commit> and <tag> objects that point at a <tree>.
422 423 424 425 426 427 428 429 430

<type>::
	Indicates that an object type is required.
	Currently one of: blob/tree/commit/tag

<file>::
	Indicates a filename - always relative to the root of
	the tree structure GIT_INDEX_FILE describes.

431 432
Symbolic Identifiers
--------------------
433
Any git command accepting any <object> can also use the following
434
symbolic notation:
435 436

HEAD::
437 438
	indicates the head of the repository (ie the contents of
	`$GIT_DIR/HEAD`)
439 440 441 442 443 444 445 446 447 448 449 450 451 452
<tag>::
	a valid tag 'name'+
	(ie the contents of `$GIT_DIR/refs/tags/<tag>`)
<head>::
	a valid head 'name'+
	(ie the contents of `$GIT_DIR/refs/heads/<head>`)
<snap>::
	a valid snapshot 'name'+
	(ie the contents of `$GIT_DIR/refs/snap/<snap>`)


File/Directory Structure
------------------------

J
Junio C Hamano 已提交
453
Please see link:repository-layout.html[repository layout] document.
454 455 456 457

Higher level SCMs may provide and manage additional information in the
GIT_DIR.

J
Junio C Hamano 已提交
458

459 460
Terminology
-----------
461
Please see link:glossary.html[glossary] document.
462 463 464 465 466 467


Environment Variables
---------------------
Various git commands use the following environment variables:

468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
The git Repository
~~~~~~~~~~~~~~~~~~
These environment variables apply to 'all' core git commands. Nb: it
is worth noting that they may be used/overridden by SCMS sitting above
git so take care if using Cogito etc

'GIT_INDEX_FILE'::
	This environment allows the specification of an alternate
	cache/index file. If not specified, the default of
	`$GIT_DIR/index` is used.

'GIT_OBJECT_DIRECTORY'::
	If the object storage directory is specified via this
	environment variable then the sha1 directories are created
	underneath - otherwise the default `$GIT_DIR/objects`
	directory is used.

'GIT_ALTERNATE_OBJECT_DIRECTORIES'::
	Due to the immutable nature of git objects, old objects can be
	archived into shared, read-only directories. This variable
488
	specifies a ":" separated list of git object directories which
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503
	can be used to search for git objects. New objects will not be
	written to these directories.

'GIT_DIR'::
	If the 'GIT_DIR' environment variable is set then it specifies
	a path to use instead of `./.git` for the base of the
	repository.

git Commits
~~~~~~~~~~~
'GIT_AUTHOR_NAME'::
'GIT_AUTHOR_EMAIL'::
'GIT_AUTHOR_DATE'::
'GIT_COMMITTER_NAME'::
'GIT_COMMITTER_EMAIL'::
504
	see gitlink:git-commit-tree[1]
505 506 507

git Diffs
~~~~~~~~~
508 509
'GIT_DIFF_OPTS'::
'GIT_EXTERNAL_DIFF'::
510
	see the "generating patches" section in :
511 512 513
	gitlink:git-diff-index[1];
	gitlink:git-diff-files[1];
	gitlink:git-diff-tree[1]
514

J
Junio C Hamano 已提交
515 516
Discussion[[Discussion]]
------------------------
517 518
include::../README[]

519 520
Author
------
521
Written by Linus Torvalds <torvalds@osdl.org> and the git-list <git@vger.kernel.org>.
522 523 524 525 526 527 528

Documentation
--------------
Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.

GIT
---
529
Part of the gitlink:git[7] suite
530