git.txt 15.5 KB
Newer Older
1
git(7)
2 3 4 5 6 7 8 9 10
======

NAME
----
git - the stupid content tracker


SYNOPSIS
--------
11
'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ARGS]
12 13 14

DESCRIPTION
-----------
15 16 17 18 19 20 21 22
Git is a fast, scalable, distributed revision control system with an
unusually rich command set that provides both high-level operations
and full access to internals.

See this link:tutorial.html[tutorial] to get started, then see
link:everyday.html[Everyday Git] for a useful minimum set of commands, and
"man git-commandname" for documentation of each command.  CVS users may
also want to read link:cvs-migration.html[CVS migration].
23

P
Petr Baudis 已提交
24 25 26
The COMMAND is either a name of a Git command (see below) or an alias
as defined in the configuration file (see gitlink:git-repo-config[1]).

27 28 29
OPTIONS
-------
--version::
F
Fredrik Kuivinen 已提交
30
	Prints the git suite version that the 'git' program came from.
31 32

--help::
F
Fredrik Kuivinen 已提交
33 34 35 36
	Prints the synopsis and a list of the most commonly used
	commands.  If a git command is named this option will bring up
	the man-page for that command. If the option '--all' or '-a' is
	given then all available commands are printed.
37 38

--exec-path::
F
Fredrik Kuivinen 已提交
39
	Path to wherever your core git programs are installed.
40 41 42 43
	This can also be controlled by setting the GIT_EXEC_PATH
	environment variable. If no path is given 'git' will print
	the current setting and then exit.

44

45 46
FURTHER DOCUMENTATION
---------------------
47

48 49
See the references above to get started using git.  The following is
probably more detail than necessary for a first-time user.
J
Junio C Hamano 已提交
50

51 52 53
The <<Discussion,Discussion>> section below and the
link:core-tutorial.html[Core tutorial] both provide introductions to the
underlying git architecture.
54

55 56
See also the link:howto-index.html[howto] documents for some useful
examples.
57

58 59
GIT COMMANDS
------------
60

61 62
We divide git into high level ("porcelain") commands and low level
("plumbing") commands.
63

64 65
Low-level commands (plumbing)
-----------------------------
66

67 68 69 70 71
Although git includes its
own porcelain layer, its low-level commands are sufficient to support
development of alternative porcelains.  Developers of such porcelains
might start by reading about gitlink:git-update-index[1] and
gitlink:git-read-tree[1].
72

73 74 75 76
We divide the low-level commands into commands that manipulate objects (in
the repository, index, and working tree), commands that interrogate and
compare objects, and commands that move objects and references between
repositories.
77

78 79
Manipulation commands
~~~~~~~~~~~~~~~~~~~~~
80
gitlink:git-apply[1]::
81 82 83
	Reads a "diff -up1" or git generated patch file and
	applies it to the working tree.

84
gitlink:git-checkout-index[1]::
J
Junio C Hamano 已提交
85
	Copy files from the index to the working tree.
86

87
gitlink:git-commit-tree[1]::
J
Junio C Hamano 已提交
88
	Creates a new commit object.
89

90
gitlink:git-hash-object[1]::
91 92
	Computes the object ID from a file.

J
Jonas Fonseca 已提交
93
gitlink:git-index-pack[1]::
J
Junio C Hamano 已提交
94
	Build pack idx file for an existing packed archive.
S
Sergey Vlasov 已提交
95

96
gitlink:git-init-db[1]::
J
Junio C Hamano 已提交
97 98
	Creates an empty git object database, or reinitialize an
	existing one.
99

100
gitlink:git-merge-index[1]::
J
Junio C Hamano 已提交
101
	Runs a merge for files needing merging.
102

103
gitlink:git-mktag[1]::
J
Junio C Hamano 已提交
104
	Creates a tag object.
105

106 107 108
gitlink:git-mktree[1]::
	Build a tree-object from ls-tree formatted text.

109
gitlink:git-pack-objects[1]::
110 111
	Creates a packed archive of objects.

112
gitlink:git-prune-packed[1]::
113 114
	Remove extra objects that are already in pack files.

115
gitlink:git-read-tree[1]::
J
Junio C Hamano 已提交
116
	Reads tree information into the index.
117

118 119 120
gitlink:git-repo-config[1]::
	Get and set options in .git/config.

121
gitlink:git-unpack-objects[1]::
122 123
	Unpacks objects out of a packed archive.

124
gitlink:git-update-index[1]::
J
Junio C Hamano 已提交
125
	Registers files in the working tree to the index.
126

127
gitlink:git-write-tree[1]::
J
Junio C Hamano 已提交
128
	Creates a tree from the index.
129

130

131 132
Interrogation commands
~~~~~~~~~~~~~~~~~~~~~~
133

134
gitlink:git-cat-file[1]::
J
Junio C Hamano 已提交
135
	Provide content or type/size information for repository objects.
136

J
Junio C Hamano 已提交
137 138 139
gitlink:git-describe[1]::
	Show the most recent tag that is reachable from a commit.

140
gitlink:git-diff-index[1]::
J
Junio C Hamano 已提交
141
	Compares content and mode of blobs between the index and repository.
142

143
gitlink:git-diff-files[1]::
J
Junio C Hamano 已提交
144
	Compares files in the working tree and the index.
145

146
gitlink:git-diff-stages[1]::
J
Junio C Hamano 已提交
147
	Compares two "merge stages" in the index.
148

149
gitlink:git-diff-tree[1]::
J
Junio C Hamano 已提交
150
	Compares the content and mode of blobs found via two tree objects.
151

152
gitlink:git-fsck-objects[1]::
J
Junio C Hamano 已提交
153
	Verifies the connectivity and validity of the objects in the database.
154

155
gitlink:git-ls-files[1]::
J
Junio C Hamano 已提交
156
	Information about files in the index and the working tree.
157

158
gitlink:git-ls-tree[1]::
J
Junio C Hamano 已提交
159
	Displays a tree object in human readable form.
160

161
gitlink:git-merge-base[1]::
J
Junio C Hamano 已提交
162
	Finds as good common ancestors as possible for a merge.
163

164
gitlink:git-name-rev[1]::
J
Junio C Hamano 已提交
165
	Find symbolic names for given revs.
166

167 168 169
gitlink:git-pack-redundant[1]::
	Find redundant pack files.

170
gitlink:git-rev-list[1]::
J
Junio C Hamano 已提交
171
	Lists commit objects in reverse chronological order.
172

173
gitlink:git-show-index[1]::
174 175
	Displays contents of a pack idx file.

176
gitlink:git-tar-tree[1]::
J
Junio C Hamano 已提交
177
	Creates a tar archive of the files in the named tree object.
178

179
gitlink:git-unpack-file[1]::
J
Junio C Hamano 已提交
180
	Creates a temporary file with a blob's contents.
181

182
gitlink:git-var[1]::
J
Junio C Hamano 已提交
183
	Displays a git logical variable.
184

185
gitlink:git-verify-pack[1]::
J
Junio C Hamano 已提交
186
	Validates packed git archive files.
187

J
Junio C Hamano 已提交
188 189
In general, the interrogate commands do not touch the files in
the working tree.
190 191


192 193 194
Synching repositories
~~~~~~~~~~~~~~~~~~~~~

195
gitlink:git-fetch-pack[1]::
J
Junio C Hamano 已提交
196 197
	Updates from a remote repository (engine for ssh and
	local transport).
198

199
gitlink:git-http-fetch[1]::
J
Junio C Hamano 已提交
200 201
	Downloads a remote git repository via HTTP by walking
	commit chain.
202

203
gitlink:git-local-fetch[1]::
J
Junio C Hamano 已提交
204 205
	Duplicates another git repository on a local system by
	walking commit chain.
206

207
gitlink:git-peek-remote[1]::
J
Junio C Hamano 已提交
208 209 210
	Lists references on a remote repository using
	upload-pack protocol (engine for ssh and local
	transport).
211

212
gitlink:git-receive-pack[1]::
213 214
	Invoked by 'git-send-pack' to receive what is pushed to it.

215
gitlink:git-send-pack[1]::
216
	Pushes to a remote repository, intelligently.
217

218 219 220
gitlink:git-http-push[1]::
	Push missing objects using HTTP/DAV.

P
Petr Baudis 已提交
221 222 223
gitlink:git-shell[1]::
	Restricted shell for GIT-only SSH access.

224
gitlink:git-ssh-fetch[1]::
J
Junio C Hamano 已提交
225 226
	Pulls from a remote repository over ssh connection by
	walking commit chain.
227

228
gitlink:git-ssh-upload[1]::
J
Junio C Hamano 已提交
229
	Helper "server-side" program used by git-ssh-fetch.
230

231
gitlink:git-update-server-info[1]::
232 233 234
	Updates auxiliary information on a dumb server to help
	clients discover references and packs on it.

235
gitlink:git-upload-pack[1]::
J
Junio C Hamano 已提交
236
	Invoked by 'git-fetch-pack' to push
237 238
	what are asked for.

239 240 241 242
gitlink:git-upload-tar[1]::
	Invoked by 'git-tar-tree --remote' to return the tar
	archive the other end asked for.

243

244 245 246 247 248 249 250 251
High-level commands (porcelain)
-------------------------------

We separate the porcelain commands into the main commands and some
ancillary user utilities.

Main porcelain commands
~~~~~~~~~~~~~~~~~~~~~~~
252

253
gitlink:git-add[1]::
J
Junio C Hamano 已提交
254
	Add paths to the index.
255

256 257 258
gitlink:git-am[1]::
	Apply patches from a mailbox, but cooler.

259
gitlink:git-applymbox[1]::
J
Junio C Hamano 已提交
260
	Apply patches from a mailbox, original version by Linus.
261

262
gitlink:git-bisect[1]::
J
Junio C Hamano 已提交
263
	Find the change that introduced a bug by binary search.
264

265
gitlink:git-branch[1]::
266 267
	Create and Show branches.

268
gitlink:git-checkout[1]::
J
Junio C Hamano 已提交
269 270
	Checkout and switch to a branch.

271
gitlink:git-cherry-pick[1]::
272
	Cherry-pick the effect of an existing commit.
J
Junio C Hamano 已提交
273

274 275 276
gitlink:git-clean[1]::
	Remove untracked files from the working tree.

277
gitlink:git-clone[1]::
278
	Clones a repository into a new directory.
J
Junio C Hamano 已提交
279

280
gitlink:git-commit[1]::
281
	Record changes to the repository.
J
Junio C Hamano 已提交
282

283
gitlink:git-diff[1]::
284
	Show changes between commits, commit and working tree, etc.
J
Junio C Hamano 已提交
285

286
gitlink:git-fetch[1]::
J
Junio C Hamano 已提交
287 288
	Download from a remote repository via various protocols.

289
gitlink:git-format-patch[1]::
290
	Prepare patches for e-mail submission.
J
Junio C Hamano 已提交
291

292
gitlink:git-grep[1]::
J
Junio C Hamano 已提交
293
	Print lines matching a pattern.
294

295
gitlink:git-log[1]::
296
	Shows commit logs.
J
Junio C Hamano 已提交
297

298
gitlink:git-ls-remote[1]::
299
	Shows references in a remote or local repository.
300

301
gitlink:git-merge[1]::
J
Junio C Hamano 已提交
302 303
	Grand unified merge driver.

304 305 306
gitlink:git-mv[1]::
	Move or rename a file, a directory, or a symlink.

307
gitlink:git-pull[1]::
308 309
	Fetch from and merge with a remote repository.

310
gitlink:git-push[1]::
311 312
	Update remote refs along with associated objects.

313
gitlink:git-rebase[1]::
J
Junio C Hamano 已提交
314
	Rebase local commits to the updated upstream head.
J
Junio C Hamano 已提交
315

316
gitlink:git-repack[1]::
317 318
	Pack unpacked objects in a repository.

319 320 321
gitlink:git-rerere[1]::
	Reuse recorded resolution of conflicted merges.

322
gitlink:git-reset[1]::
J
Junio C Hamano 已提交
323 324
	Reset current HEAD to the specified state.

325
gitlink:git-resolve[1]::
326
	Merge two commits.
327

328
gitlink:git-revert[1]::
329 330
	Revert an existing commit.

331 332 333
gitlink:git-rm[1]::
	Remove files from the working tree and from the index.

334
gitlink:git-shortlog[1]::
335 336
	Summarizes 'git log' output.

J
Jon Loeliger 已提交
337 338 339
gitlink:git-show[1]::
	Show one commit log and its diff.

340
gitlink:git-show-branch[1]::
341 342
	Show branches and their commits.

343
gitlink:git-status[1]::
344
	Shows the working tree status.
345

346
gitlink:git-verify-tag[1]::
347 348
	Check the GPG signature of tag.

349
gitlink:git-whatchanged[1]::
350 351
	Shows commit logs and differences they introduce.

352

353
Ancillary Commands
354
~~~~~~~~~~~~~~~~~~
355 356
Manipulators:

357
gitlink:git-applypatch[1]::
358
	Apply one patch extracted from an e-mail.
359

360
gitlink:git-archimport[1]::
J
Junio C Hamano 已提交
361 362
	Import an arch repository into git.

363
gitlink:git-convert-objects[1]::
J
Junio C Hamano 已提交
364
	Converts old-style git repository.
365

366
gitlink:git-cvsimport[1]::
367 368
	Salvage your data out of another SCM people love to hate.

369 370 371
gitlink:git-cvsexportcommit[1]::
	Export a single commit to a CVS checkout.

372 373 374
gitlink:git-cvsserver[1]::
	A CVS server emulator for git.

J
Junio C Hamano 已提交
375
gitlink:git-lost-found[1]::
J
Junio C Hamano 已提交
376 377
	Recover lost refs that luckily have not yet been pruned.

378
gitlink:git-merge-one-file[1]::
J
Junio C Hamano 已提交
379
	The standard helper program to use with `git-merge-index`.
380

381
gitlink:git-prune[1]::
J
Junio C Hamano 已提交
382
	Prunes all unreachable objects from the object database.
383

384 385 386
gitlink:git-quiltimport[1]::
	Applies a quilt patchset onto the current branch.

387
gitlink:git-relink[1]::
388 389
	Hardlink common objects in local repositories.

390 391 392
gitlink:git-svnimport[1]::
	Import a SVN repository into git.

393
gitlink:git-sh-setup[1]::
394 395
	Common git shell script setup code.

396
gitlink:git-symbolic-ref[1]::
J
Junio C Hamano 已提交
397
	Read and modify symbolic refs.
398

399
gitlink:git-tag[1]::
J
Junio C Hamano 已提交
400
	An example script to create a tag object signed with GPG.
401

402 403 404
gitlink:git-update-ref[1]::
	Update the object name stored in a ref safely.

405

406
Interrogators:
407

408 409 410 411 412 413
gitlink:git-annotate[1]::
	Annotate file lines with commit info.

gitlink:git-blame[1]::
	Blame file lines on commits.

414 415 416
gitlink:git-check-ref-format[1]::
	Make sure ref name is well formed.

417
gitlink:git-cherry[1]::
418
	Find commits not merged upstream.
419

420
gitlink:git-count-objects[1]::
421 422
	Count unpacked number of objects and their disk consumption.

423
gitlink:git-daemon[1]::
424
	A really simple server for git repositories.
J
Junio C Hamano 已提交
425

426 427 428
gitlink:git-fmt-merge-msg[1]::
	Produce a merge commit message.

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

432 433 434
gitlink:git-imap-send[1]::
	Dump a mailbox from stdin into an imap folder.

435
gitlink:git-mailinfo[1]::
J
Junio C Hamano 已提交
436 437 438
	Extracts patch and authorship information from a single
	e-mail message, optionally transliterating the commit
	message into utf-8.
439

440
gitlink:git-mailsplit[1]::
J
Junio C Hamano 已提交
441 442
	A stupid program to split UNIX mbox format mailbox into
	individual pieces of e-mail.
443

444 445 446
gitlink:git-merge-tree[1]::
	Show three-way merge without touching index.

447
gitlink:git-patch-id[1]::
448
	Compute unique ID for a patch.
449

450
gitlink:git-parse-remote[1]::
J
Junio C Hamano 已提交
451
	Routines to help parsing `$GIT_DIR/remotes/` files.
J
Junio C Hamano 已提交
452

453
gitlink:git-request-pull[1]::
J
Junio C Hamano 已提交
454
	git-request-pull.
J
Junio C Hamano 已提交
455

456
gitlink:git-rev-parse[1]::
J
Junio C Hamano 已提交
457 458
	Pick out and massage parameters.

459
gitlink:git-send-email[1]::
460
	Send patch e-mails out of "format-patch --mbox" output.
461

462
gitlink:git-symbolic-ref[1]::
463 464
	Read and modify symbolic refs.

465
gitlink:git-stripspace[1]::
J
Junio C Hamano 已提交
466
	Filter out empty lines.
467 468


J
Junio C Hamano 已提交
469 470
Commands not yet documented
---------------------------
471

472
gitlink:gitk[1]::
J
Junio C Hamano 已提交
473
	The gitk repository browser.
474 475


J
Junio C Hamano 已提交
476 477 478
Configuration Mechanism
-----------------------

J
Junio C Hamano 已提交
479
Starting from 0.99.9 (actually mid 0.99.8.GIT), `.git/config` file
J
Junio C Hamano 已提交
480 481 482 483 484 485
is used to hold per-repository configuration options.  It is a
simple text file modelled after `.ini` format familiar to some
people.  Here is an example:

------------
#
J
Junio C Hamano 已提交
486
# A '#' or ';' character indicates a comment.
J
Junio C Hamano 已提交
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504
#

; core variables
[core]
	; Don't trust file modes
	filemode = false

; user identity
[user]
	name = "Junio C Hamano"
	email = "junkio@twinsun.com"

------------

Various commands read from the configuration file and adjust
their operation accordingly.


505
Identifier Terminology
506 507
----------------------
<object>::
J
Junio C Hamano 已提交
508
	Indicates the object name for any type of object.
509 510

<blob>::
J
Junio C Hamano 已提交
511
	Indicates a blob object name.
512 513

<tree>::
J
Junio C Hamano 已提交
514
	Indicates a tree object name.
515 516

<commit>::
J
Junio C Hamano 已提交
517
	Indicates a commit object name.
518 519

<tree-ish>::
J
Junio C Hamano 已提交
520
	Indicates a tree, commit or tag object name.  A
521 522 523
	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>.
524 525 526

<type>::
	Indicates that an object type is required.
J
Junio C Hamano 已提交
527
	Currently one of: `blob`, `tree`, `commit`, or `tag`.
528 529

<file>::
J
Junio C Hamano 已提交
530 531
	Indicates a filename - almost always relative to the
	root of the tree structure `GIT_INDEX_FILE` describes.
532

533 534
Symbolic Identifiers
--------------------
535
Any git command accepting any <object> can also use the following
536
symbolic notation:
537 538

HEAD::
J
Junio C Hamano 已提交
539 540 541
	indicates the head of the current branch (i.e. the
	contents of `$GIT_DIR/HEAD`).

542
<tag>::
J
Junio C Hamano 已提交
543 544 545
	a valid tag 'name'
	(i.e. the contents of `$GIT_DIR/refs/tags/<tag>`).

546
<head>::
J
Junio C Hamano 已提交
547 548 549
	a valid head 'name'
	(i.e. the contents of `$GIT_DIR/refs/heads/<head>`).

550 551 552 553

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

J
Junio C Hamano 已提交
554
Please see link:repository-layout.html[repository layout] document.
555

556 557
Read link:hooks.html[hooks] for more details about each hook.

558
Higher level SCMs may provide and manage additional information in the
J
Junio C Hamano 已提交
559
`$GIT_DIR`.
560

J
Junio C Hamano 已提交
561

562 563
Terminology
-----------
564
Please see link:glossary.html[glossary] document.
565 566 567 568 569 570


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

571 572 573 574
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
J
Junio C Hamano 已提交
575
git so take care if using Cogito etc.
576 577 578

'GIT_INDEX_FILE'::
	This environment allows the specification of an alternate
579 580
	index file. If not specified, the default of `$GIT_DIR/index`
	is used.
581 582 583 584 585 586 587 588 589 590

'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
591
	specifies a ":" separated list of git object directories which
592 593 594 595
	can be used to search for git objects. New objects will not be
	written to these directories.

'GIT_DIR'::
J
Junio C Hamano 已提交
596 597 598
	If the 'GIT_DIR' environment variable is set then it
	specifies a path to use instead of the default `.git`
	for the base of the repository.
599 600 601 602 603 604 605 606

git Commits
~~~~~~~~~~~
'GIT_AUTHOR_NAME'::
'GIT_AUTHOR_EMAIL'::
'GIT_AUTHOR_DATE'::
'GIT_COMMITTER_NAME'::
'GIT_COMMITTER_EMAIL'::
607
	see gitlink:git-commit-tree[1]
608 609 610

git Diffs
~~~~~~~~~
611 612
'GIT_DIFF_OPTS'::
'GIT_EXTERNAL_DIFF'::
613
	see the "generating patches" section in :
614 615 616
	gitlink:git-diff-index[1];
	gitlink:git-diff-files[1];
	gitlink:git-diff-tree[1]
617

J
Junio C Hamano 已提交
618 619
Discussion[[Discussion]]
------------------------
620
include::README[]
621

622 623
Authors
-------
624 625 626 627
* git's founding father is Linus Torvalds <torvalds@osdl.org>.
* The current git nurse is Junio C Hamano <junkio@cox.net>.
* The git potty was written by Andres Ericsson <ae@op5.se>.
* General upbringing is handled by the git-list <git@vger.kernel.org>.
628 629 630

Documentation
--------------
631 632 633
The documentation for git suite was started by David Greaves
<david@dgreaves.com>, and later enhanced greatly by the
contributors on the git-list <git@vger.kernel.org>.
634 635 636

GIT
---
637
Part of the gitlink:git[7] suite
638