git.txt 13.7 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 23 24 25 26
'git' is both a program and a directory content tracker system.
The program 'git' is just a wrapper to reach the core git programs
(or a potty if you like, as it's not exactly porcelain but still
brings your stuff to the plumbing).

OPTIONS
-------
--version::
	prints the git suite version that the 'git' program came from.

--help::
	prints the synopsis and a list of available commands.
27 28
	If a git command is named this option will bring up the
	man-page for that command.
29 30 31 32 33 34 35 36 37

--exec-path::
	path to wherever your core git programs are installed.
	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.

CORE GIT COMMANDS
-----------------
38 39 40
Before reading this cover to cover, you may want to take a look
at the link:tutorial.html[tutorial] document.

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

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

49 50 51 52 53
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.


54 55 56 57 58 59 60 61 62
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
63
the repository, the index and the working fileset, those that
64 65
interrogate and compare them, and those that moves objects and
references between repositories.
66

J
Junio C Hamano 已提交
67 68 69 70
In addition, git itself comes with a spartan set of porcelain
commands.  They are usable but are not meant to compete with real
Porcelains.

71
There are also some ancillary programs that can be viewed as useful
72 73 74
aids for using the core commands but which are unlikely to be used by
SCMs layered over git.

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

81
gitlink:git-checkout-index[1]::
82
	Copy files from the index to the working directory
83

84
gitlink:git-commit-tree[1]::
85 86
	Creates a new commit object

87 88 89
gitlink:git-config-set[1]::
	Set options in .git/config.

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

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

96
gitlink:git-init-db[1]::
97 98
	Creates an empty git object database

99
gitlink:git-merge-index[1]::
100
	Runs a merge for files needing merging
101

102
gitlink:git-mktag[1]::
103 104
	Creates a tag object

105
gitlink:git-pack-objects[1]::
106 107
	Creates a packed archive of objects.

108
gitlink:git-prune-packed[1]::
109 110
	Remove extra objects that are already in pack files.

111
gitlink:git-read-tree[1]::
112
	Reads tree information into the directory index
113

114
gitlink:git-unpack-objects[1]::
115 116
	Unpacks objects out of a packed archive.

117
gitlink:git-update-index[1]::
118 119
	Modifies the index or directory cache

120
gitlink:git-write-tree[1]::
121
	Creates a tree from the current index
122

123

124 125
Interrogation commands
~~~~~~~~~~~~~~~~~~~~~~
126

127
gitlink:git-cat-file[1]::
128 129
	Provide content or type information for repository objects

130
gitlink:git-diff-index[1]::
131
	Compares content and mode of blobs between the index and repository
132

133
gitlink:git-diff-files[1]::
134
	Compares files in the working tree and the index
135

136
gitlink:git-diff-stages[1]::
137 138
	Compares two "merge stages" in the index file.

139
gitlink:git-diff-tree[1]::
140 141
	Compares the content and mode of blobs found via two tree objects

142
gitlink:git-fsck-objects[1]::
143 144
	Verifies the connectivity and validity of the objects in the database

145
gitlink:git-ls-files[1]::
146
	Information about files in the index/working directory
147

148
gitlink:git-ls-tree[1]::
149 150
	Displays a tree object in human readable form

151
gitlink:git-merge-base[1]::
152
	Finds as good a common ancestor as possible for a merge
153

154 155 156
gitlink:git-name-rev[1]::
	Find symbolic names for given revs

157
gitlink:git-rev-list[1]::
158 159
	Lists commit objects in reverse chronological order

160
gitlink:git-show-index[1]::
161 162
	Displays contents of a pack idx file.

163
gitlink:git-tar-tree[1]::
164 165
	Creates a tar archive of the files in the named tree

166
gitlink:git-unpack-file[1]::
167 168
	Creates a temporary file with a blob's contents

169
gitlink:git-var[1]::
170 171
	Displays a git logical variable

172
gitlink:git-verify-pack[1]::
173
	Validates packed git archive files
174

175 176 177 178
The interrogate commands may create files - and you can force them to
touch the working file set - but in general they don't


179 180 181
Synching repositories
~~~~~~~~~~~~~~~~~~~~~

182
gitlink:git-clone-pack[1]::
183 184 185
	Clones a repository into the current repository (engine
	for ssh and local transport)

186
gitlink:git-fetch-pack[1]::
187 188
	Updates from a remote repository.

189
gitlink:git-http-fetch[1]::
190
	Downloads a remote git repository via HTTP
191

192
gitlink:git-local-fetch[1]::
193
	Duplicates another git repository on a local system
194

195
gitlink:git-peek-remote[1]::
196
	Lists references on a remote repository using upload-pack protocol.
197

198
gitlink:git-receive-pack[1]::
199 200
	Invoked by 'git-send-pack' to receive what is pushed to it.

201
gitlink:git-send-pack[1]::
202
	Pushes to a remote repository, intelligently.
203

P
Petr Baudis 已提交
204 205 206
gitlink:git-shell[1]::
	Restricted shell for GIT-only SSH access.

207
gitlink:git-ssh-fetch[1]::
208
	Pulls from a remote repository over ssh connection
209

210
gitlink:git-ssh-upload[1]::
J
Junio C Hamano 已提交
211
	Helper "server-side" program used by git-ssh-fetch
212

213
gitlink:git-update-server-info[1]::
214 215 216
	Updates auxiliary information on a dumb server to help
	clients discover references and packs on it.

217
gitlink:git-upload-pack[1]::
218 219 220
	Invoked by 'git-clone-pack' and 'git-fetch-pack' to push
	what are asked for.

221

J
Junio C Hamano 已提交
222 223
Porcelain-ish Commands
----------------------
224

225
gitlink:git-add[1]::
226 227
	Add paths to the index file.

228 229 230
gitlink:git-am[1]::
	Apply patches from a mailbox, but cooler.

231
gitlink:git-applymbox[1]::
232 233
	Apply patches from a mailbox.

234
gitlink:git-bisect[1]::
235 236
	Find the change that introduced a bug.

237
gitlink:git-branch[1]::
238 239
	Create and Show branches.

240
gitlink:git-checkout[1]::
J
Junio C Hamano 已提交
241 242
	Checkout and switch to a branch.

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

246
gitlink:git-clone[1]::
247
	Clones a repository into a new directory.
J
Junio C Hamano 已提交
248

249
gitlink:git-commit[1]::
250
	Record changes to the repository.
J
Junio C Hamano 已提交
251

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

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

258
gitlink:git-format-patch[1]::
259
	Prepare patches for e-mail submission.
J
Junio C Hamano 已提交
260

261
gitlink:git-grep[1]::
262 263
	Print lines matching a pattern

264
gitlink:git-log[1]::
265
	Shows commit logs.
J
Junio C Hamano 已提交
266

267
gitlink:git-ls-remote[1]::
268
	Shows references in a remote or local repository.
269

270
gitlink:git-merge[1]::
J
Junio C Hamano 已提交
271 272
	Grand unified merge driver.

273 274 275
gitlink:git-mv[1]::
	Move or rename a file, a directory, or a symlink.

276
gitlink:git-octopus[1]::
277 278
	Merge more than two commits.

279
gitlink:git-pull[1]::
280 281
	Fetch from and merge with a remote repository.

282
gitlink:git-push[1]::
283 284
	Update remote refs along with associated objects.

285
gitlink:git-rebase[1]::
286
	Rebase local commits to new upstream head.
J
Junio C Hamano 已提交
287

288
gitlink:git-repack[1]::
289 290
	Pack unpacked objects in a repository.

291
gitlink:git-reset[1]::
J
Junio C Hamano 已提交
292 293
	Reset current HEAD to the specified state.

294
gitlink:git-resolve[1]::
295
	Merge two commits.
296

297
gitlink:git-revert[1]::
298 299
	Revert an existing commit.

300
gitlink:git-shortlog[1]::
301 302
	Summarizes 'git log' output.

303
gitlink:git-show-branch[1]::
304 305
	Show branches and their commits.

306
gitlink:git-status[1]::
307
	Shows the working tree status.
308

309
gitlink:git-verify-tag[1]::
310 311
	Check the GPG signature of tag.

312
gitlink:git-whatchanged[1]::
313 314
	Shows commit logs and differences they introduce.

315

316 317
Ancillary Commands
------------------
318 319
Manipulators:

320
gitlink:git-applypatch[1]::
321
	Apply one patch extracted from an e-mail.
322

323
gitlink:git-archimport[1]::
J
Junio C Hamano 已提交
324 325
	Import an arch repository into git.

326
gitlink:git-convert-objects[1]::
327
	Converts old-style git repository
328

329
gitlink:git-cvsimport[1]::
330 331
	Salvage your data out of another SCM people love to hate.

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

335
gitlink:git-merge-one-file[1]::
J
Junio C Hamano 已提交
336
	The standard helper program to use with "git-merge-index"
337

338
gitlink:git-prune[1]::
339 340
	Prunes all unreachable objects from the object database

341
gitlink:git-relink[1]::
342 343
	Hardlink common objects in local repositories.

344 345 346
gitlink:git-svnimport[1]::
	Import a SVN repository into git.

347
gitlink:git-sh-setup[1]::
348 349
	Common git shell script setup code.

350 351 352
gitlink:git-symbolic-ref[1]::
	Read and modify symbolic refs

353
gitlink:git-tag[1]::
354 355
	An example script to create a tag object signed with GPG

356 357 358
gitlink:git-update-ref[1]::
	Update the object name stored in a ref safely.

359

360
Interrogators:
361

362 363 364
gitlink:git-check-ref-format[1]::
	Make sure ref name is well formed.

365
gitlink:git-cherry[1]::
366
	Find commits not merged upstream.
367

368
gitlink:git-count-objects[1]::
369 370
	Count unpacked number of objects and their disk consumption.

371
gitlink:git-daemon[1]::
372
	A really simple server for git repositories.
J
Junio C Hamano 已提交
373

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

377
gitlink:git-mailinfo[1]::
378 379
	Extracts patch from a single e-mail message.

380
gitlink:git-mailsplit[1]::
381 382
	git-mailsplit.

383
gitlink:git-patch-id[1]::
384
	Compute unique ID for a patch.
385

386
gitlink:git-parse-remote[1]::
J
Junio C Hamano 已提交
387 388
	Routines to help parsing $GIT_DIR/remotes/

389
gitlink:git-request-pull[1]::
J
Junio C Hamano 已提交
390
	git-request-pull.
J
Junio C Hamano 已提交
391

392
gitlink:git-rev-parse[1]::
J
Junio C Hamano 已提交
393 394
	Pick out and massage parameters.

395
gitlink:git-send-email[1]::
396
	Send patch e-mails out of "format-patch --mbox" output.
397

398 399 400
gitlink:git-symbolic-refs[1]::
	Read and modify symbolic refs.

401
gitlink:git-stripspace[1]::
J
Junio C Hamano 已提交
402
	Filter out empty lines.
403 404


J
Junio C Hamano 已提交
405 406
Commands not yet documented
---------------------------
407

408
gitlink:gitk[1]::
409 410 411
	gitk.


J
Junio C Hamano 已提交
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
Configuration Mechanism
-----------------------

Starting from 0.99.9 (actually mid 0.99.8.GIT), .git/config file
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:

------------
#
# This is the config file, and
# a '#' or ';' character indicates
# a comment
#

; 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.


443
Identifier Terminology
444 445
----------------------
<object>::
446
	Indicates the sha1 identifier for any type of object
447 448 449 450 451 452 453 454 455 456 457

<blob>::
	Indicates a blob object sha1 identifier

<tree>::
	Indicates a tree object sha1 identifier

<commit>::
	Indicates a commit object sha1 identifier

<tree-ish>::
458 459 460 461
	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>.
462 463 464 465 466 467 468 469 470

<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.

471 472
Symbolic Identifiers
--------------------
473
Any git command accepting any <object> can also use the following
474
symbolic notation:
475 476

HEAD::
477 478
	indicates the head of the repository (ie the contents of
	`$GIT_DIR/HEAD`)
479 480 481 482 483 484 485 486 487 488 489 490 491 492
<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 已提交
493
Please see link:repository-layout.html[repository layout] document.
494 495 496 497

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

J
Junio C Hamano 已提交
498

499 500
Terminology
-----------
501
Please see link:glossary.html[glossary] document.
502 503 504 505 506 507


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

508 509 510 511 512 513 514 515
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
516 517
	index file. If not specified, the default of `$GIT_DIR/index`
	is used.
518 519 520 521 522 523 524 525 526 527

'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
528
	specifies a ":" separated list of git object directories which
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543
	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'::
544
	see gitlink:git-commit-tree[1]
545 546 547

git Diffs
~~~~~~~~~
548 549
'GIT_DIFF_OPTS'::
'GIT_EXTERNAL_DIFF'::
550
	see the "generating patches" section in :
551 552 553
	gitlink:git-diff-index[1];
	gitlink:git-diff-files[1];
	gitlink:git-diff-tree[1]
554

J
Junio C Hamano 已提交
555 556
Discussion[[Discussion]]
------------------------
557 558
include::../README[]

559 560 561 562 563 564
Authors
-------
	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>.
565 566 567 568 569 570 571

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

GIT
---
572
Part of the gitlink:git[7] suite
573