git.txt 15.6 KB
Newer Older
1
git(7)
2
======
3
v0.99.5, Aug 2005
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

NAME
----
git - the stupid content tracker


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

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

This is reference information for the core git commands.

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

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

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

30 31 32 33 34
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.


35 36 37 38 39 40 41 42 43
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
44 45 46
the repository, the cache and the working fileset, those that
interrogate and compare them, and those that moves objects and
references between repositories.
47

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

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

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

J
Junio C Hamano 已提交
62
link:git-checkout-index.html[git-checkout-index]::
63
	Copy files from the cache to the working directory
J
Junio C Hamano 已提交
64
	Previously this command was known as git-checkout-cache.
65 66 67 68

link:git-commit-tree.html[git-commit-tree]::
	Creates a new commit object

69 70 71
link:git-hash-object.html[git-hash-object]::
	Computes the object ID from a file.

72 73 74
link:git-init-db.html[git-init-db]::
	Creates an empty git object database

J
Junio C Hamano 已提交
75
link:git-merge-index.html[git-merge-index]::
76
	Runs a merge for files needing merging
J
Junio C Hamano 已提交
77
	Previously this command was known as git-merge-cache.
78 79 80 81

link:git-mktag.html[git-mktag]::
	Creates a tag object

82 83 84 85 86 87
link:git-pack-objects.html[git-pack-objects]::
	Creates a packed archive of objects.

link:git-prune-packed.html[git-prune-packed]::
	Remove extra objects that are already in pack files.

88 89 90
link:git-read-tree.html[git-read-tree]::
	Reads tree information into the directory cache

91 92 93
link:git-unpack-objects.html[git-unpack-objects]::
	Unpacks objects out of a packed archive.

J
Junio C Hamano 已提交
94
link:git-update-index.html[git-update-index]::
95
	Modifies the index or directory cache
J
Junio C Hamano 已提交
96
	Previously this command was known as git-update-cache.
97 98 99 100

link:git-write-tree.html[git-write-tree]::
	Creates a tree from the current cache

101

102 103
Interrogation commands
~~~~~~~~~~~~~~~~~~~~~~
104

105 106 107
link:git-cat-file.html[git-cat-file]::
	Provide content or type information for repository objects

J
Junio C Hamano 已提交
108
link:git-diff-index.html[git-diff-index]::
109
	Compares content and mode of blobs between the cache and repository
J
Junio C Hamano 已提交
110
	Previously this command was known as git-diff-cache.
111 112 113 114

link:git-diff-files.html[git-diff-files]::
	Compares files in the working tree and the cache

115 116 117
link:git-diff-stages.html[git-diff-stages]::
	Compares two "merge stages" in the index file.

118 119 120
link:git-diff-tree.html[git-diff-tree]::
	Compares the content and mode of blobs found via two tree objects

121 122 123
link:git-export.html[git-export]::
	Exports each commit and a diff against each of its parents

J
Junio C Hamano 已提交
124
link:git-fsck-objects.html[git-fsck-objects]::
125
	Verifies the connectivity and validity of the objects in the database
J
Junio C Hamano 已提交
126
	Previously this command was known as git-fsck-cache.
127 128 129 130 131 132 133

link:git-ls-files.html[git-ls-files]::
	Information about files in the cache/working directory

link:git-ls-tree.html[git-ls-tree]::
	Displays a tree object in human readable form

134 135
link:git-merge-base.html[git-merge-base]::
	Finds as good a common ancestor as possible for a merge
136 137 138 139 140 141 142

link:git-rev-list.html[git-rev-list]::
	Lists commit objects in reverse chronological order

link:git-rev-tree.html[git-rev-tree]::
	Provides the revision tree for one or more commits

143 144 145
link:git-show-index.html[git-show-index]::
	Displays contents of a pack idx file.

146 147 148 149 150 151
link:git-tar-tree.html[git-tar-tree]::
	Creates a tar archive of the files in the named tree

link:git-unpack-file.html[git-unpack-file]::
	Creates a temporary file with a blob's contents

152 153 154
link:git-var.html[git-var]::
	Displays a git logical variable

155 156 157
link:git-verify-pack.html[git-verify-pack]::
	Validates packed GIT archive files

158 159 160 161
The interrogate commands may create files - and you can force them to
touch the working file set - but in general they don't


162 163 164
Synching repositories
~~~~~~~~~~~~~~~~~~~~~

165 166 167 168
link:git-clone-pack.html[git-clone-pack]::
	Clones a repository into the current repository (engine
	for ssh and local transport)

169 170 171
link:git-fetch-pack.html[git-fetch-pack]::
	Updates from a remote repository.

J
Junio C Hamano 已提交
172
link:git-http-fetch.html[git-http-fetch]::
173
	Downloads a remote GIT repository via HTTP
J
Junio C Hamano 已提交
174
	Previously this command was known as git-http-pull.
175

J
Junio C Hamano 已提交
176
link:git-local-fetch.html[git-local-fetch]::
177
	Duplicates another GIT repository on a local system
J
Junio C Hamano 已提交
178
	Previously this command was known as git-local-pull.
179

180 181
link:git-peek-remote.html[git-peek-remote]::
	Lists references on a remote repository using upload-pack protocol.
182 183 184 185

link:git-receive-pack.html[git-receive-pack]::
	Invoked by 'git-send-pack' to receive what is pushed to it.

186 187
link:git-send-pack.html[git-send-pack]::
	Pushes to a remote repository, intelligently.
188

J
Junio C Hamano 已提交
189
link:git-ssh-fetch.html[git-ssh-fetch]::
190
	Pulls from a remote repository over ssh connection
J
Junio C Hamano 已提交
191
	Previously this command was known as git-ssh-pull.
192

J
Junio C Hamano 已提交
193 194 195
link:git-ssh-upload.html[git-ssh-upload]::
	Helper "server-side" program used by git-ssh-fetch
	Previously this command was known as git-ssh-push.
196

197 198 199 200
link:git-update-server-info.html[git-update-server-info]::
	Updates auxiliary information on a dumb server to help
	clients discover references and packs on it.

201 202 203 204
link:git-upload-pack.html[git-upload-pack]::
	Invoked by 'git-clone-pack' and 'git-fetch-pack' to push
	what are asked for.

205

J
Junio C Hamano 已提交
206 207
Porcelain-ish Commands
----------------------
208

J
Junio C Hamano 已提交
209
link:git-add.html[git-add]::
210
	Add paths to the index file.
J
Junio C Hamano 已提交
211
	Previously this command was known as git-add-script.
212

213 214 215
link:git-applymbox.html[git-applymbox]::
	Apply patches from a mailbox.

J
Junio C Hamano 已提交
216
link:git-bisect.html[git-bisect]::
217
	Find the change that introduced a bug.
J
Junio C Hamano 已提交
218
	Previously this command was known as git-bisect-script.
219

J
Junio C Hamano 已提交
220
link:git-branch.html[git-branch]::
221
	Create and Show branches.
J
Junio C Hamano 已提交
222
	Previously this command was known as git-branch-script.
223

J
Junio C Hamano 已提交
224
link:git-checkout.html[git-checkout]::
J
Junio C Hamano 已提交
225
	Checkout and switch to a branch.
J
Junio C Hamano 已提交
226
	Previously this command was known as git-checkout-script.
J
Junio C Hamano 已提交
227

J
Junio C Hamano 已提交
228
link:git-cherry-pick.html[git-cherry-pick]::
229
	Cherry-pick the effect of an existing commit.
J
Junio C Hamano 已提交
230
	Previously this command was known as git-cherry-pick-script.
J
Junio C Hamano 已提交
231

J
Junio C Hamano 已提交
232
link:git-clone.html[git-clone]::
233
	Clones a repository into a new directory.
J
Junio C Hamano 已提交
234
	Previously this command was known as git-clone-script.
J
Junio C Hamano 已提交
235

J
Junio C Hamano 已提交
236
link:git-commit.html[git-commit]::
237
	Record changes to the repository.
J
Junio C Hamano 已提交
238
	Previously this command was known as git-commit-script.
J
Junio C Hamano 已提交
239

J
Junio C Hamano 已提交
240 241 242 243
link:git-diff.html[git-diff]::
	git-diff.
	Previously this command was known as git-diff-script.

J
Junio C Hamano 已提交
244
link:git-fetch.html[git-fetch]::
J
Junio C Hamano 已提交
245
	Download from a remote repository via various protocols.
J
Junio C Hamano 已提交
246
	Previously this command was known as git-fetch-script.
J
Junio C Hamano 已提交
247

J
Junio C Hamano 已提交
248 249 250 251
link:git-format-patch.html[git-format-patch]::
	git-format-patch.
	Previously this command was known as git-format-patch-script.

J
Junio C Hamano 已提交
252
link:git-log.html[git-log]::
253
	Shows commit logs.
J
Junio C Hamano 已提交
254
	Previously this command was known as git-log-script.
J
Junio C Hamano 已提交
255

J
Junio C Hamano 已提交
256
link:git-ls-remote.html[git-ls-remote]::
257
	Shows references in a remote or local repository.
J
Junio C Hamano 已提交
258
	Previously this command was known as git-ls-remote-script.
259

J
Junio C Hamano 已提交
260 261 262
link:git-merge.html[git-merge]::
	Grand unified merge driver.

J
Junio C Hamano 已提交
263
link:git-octopus.html[git-octopus]::
264
	Merge more than two commits.
J
Junio C Hamano 已提交
265
	Previously this command was known as git-octopus-script.
266

J
Junio C Hamano 已提交
267
link:git-pull.html[git-pull]::
268
	Fetch from and merge with a remote repository.
J
Junio C Hamano 已提交
269
	Previously this command was known as git-pull-script.
270

J
Junio C Hamano 已提交
271
link:git-push.html[git-push]::
272
	Update remote refs along with associated objects.
J
Junio C Hamano 已提交
273
	Previously this command was known as git-push-script.
274

J
Junio C Hamano 已提交
275
link:git-rebase.html[git-rebase]::
276
	Rebase local commits to new upstream head.
J
Junio C Hamano 已提交
277
	Previously this command was known as git-rebase-script.
J
Junio C Hamano 已提交
278

J
Junio C Hamano 已提交
279
link:git-rename.html[git-rename]::
280
	Rename files and directories.
J
Junio C Hamano 已提交
281
	Previously this command was known as git-rename-script.
J
Junio C Hamano 已提交
282

J
Junio C Hamano 已提交
283
link:git-repack.html[git-repack]::
284
	Pack unpacked objects in a repository.
J
Junio C Hamano 已提交
285
	Previously this command was known as git-repack-script.
286

J
Junio C Hamano 已提交
287
link:git-reset.html[git-reset]::
J
Junio C Hamano 已提交
288
	Reset current HEAD to the specified state.
J
Junio C Hamano 已提交
289
	Previously this command was known as git-reset-script.
J
Junio C Hamano 已提交
290

J
Junio C Hamano 已提交
291
link:git-resolve.html[git-resolve]::
292
	Merge two commits.
J
Junio C Hamano 已提交
293
	Previously this command was known as git-resolve-script.
294

J
Junio C Hamano 已提交
295
link:git-revert.html[git-revert]::
296
	Revert an existing commit.
J
Junio C Hamano 已提交
297
	Previously this command was known as git-revert-script.
298 299 300 301 302 303 304

link:git-shortlog.html[git-shortlog]::
	Summarizes 'git log' output.

link:git-show-branch.html[git-show-branch]::
	Show branches and their commits.

J
Junio C Hamano 已提交
305
link:git-status.html[git-status]::
306
	Shows the working tree status.
J
Junio C Hamano 已提交
307
	Previously this command was known as git-status-script.
308

J
Junio C Hamano 已提交
309
link:git-verify-tag.html[git-verify-tag]::
310
	Check the GPG signature of tag.
J
Junio C Hamano 已提交
311
	Previously this command was known as git-verify-tag-script.
312

313 314 315
link:git-whatchanged.html[git-whatchanged]::
	Shows commit logs and differences they introduce.

316

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

321 322
link:git-applypatch.html[git-applypatch]::
	Apply one patch extracted from an e-mail.
323

J
Junio C Hamano 已提交
324
link:git-archimport.html[git-archimport]::
J
Junio C Hamano 已提交
325
	Import an arch repository into git.
J
Junio C Hamano 已提交
326
	Previously this command was known as git-archimport-script.
J
Junio C Hamano 已提交
327

J
Junio C Hamano 已提交
328
link:git-convert-objects.html[git-convert-objects]::
329
	Converts old-style GIT repository
J
Junio C Hamano 已提交
330
	Previously this command was known as git-convert-cache.
331

J
Junio C Hamano 已提交
332
link:git-cvsimport.html[git-cvsimport]::
333
	Salvage your data out of another SCM people love to hate.
J
Junio C Hamano 已提交
334
	Previously this command was known as git-cvsimport-script.
335

J
Junio C Hamano 已提交
336 337 338
link:git-merge-one-file.html[git-merge-one-file]::
	The standard helper program to use with "git-merge-index"
	Previously this command was known as git-merge-one-file-script.
339

J
Junio C Hamano 已提交
340
link:git-prune.html[git-prune]::
341
	Prunes all unreachable objects from the object database
J
Junio C Hamano 已提交
342
	Previously this command was known as git-prune-script.
343

J
Junio C Hamano 已提交
344
link:git-relink.html[git-relink]::
345
	Hardlink common objects in local repositories.
J
Junio C Hamano 已提交
346
	Previously this command was known as git-relink-script.
347

J
Junio C Hamano 已提交
348
link:git-sh-setup.html[git-sh-setup]::
349
	Common git shell script setup code.
J
Junio C Hamano 已提交
350
	Previously this command was known as git-sh-setup-script.
351

J
Junio C Hamano 已提交
352
link:git-tag.html[git-tag]::
353
	An example script to create a tag object signed with GPG
J
Junio C Hamano 已提交
354
	Previously this command was known as git-tag-script.
355 356


357
Interrogators:
358

J
Junio C Hamano 已提交
359 360 361
link:git-build-rev-cache.html[git-build-rev-cache]::
	Create or update a rev-cache file.

362 363
link:git-cherry.html[git-cherry]::
	Find commits not merged upstream.
364

J
Junio C Hamano 已提交
365
link:git-count-objects.html[git-count-objects]::
366
	Count unpacked number of objects and their disk consumption.
J
Junio C Hamano 已提交
367
	Previously this command was known as git-count-objects-script.
368

J
Junio C Hamano 已提交
369 370 371
link:git-daemon.html[git-daemon]::
	A really simple server for GIT repositories.

372
link:git-diff-helper.html[git-diff-helper]::
373 374
	Generates patch format output for git-diff-*

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

378 379 380 381 382 383 384 385
link:git-mailinfo.html[git-mailinfo]::
	Extracts patch from a single e-mail message.

link:git-mailsplit.html[git-mailsplit]::
	git-mailsplit.

link:git-patch-id.html[git-patch-id]::
	Compute unique ID for a patch.
386

J
Junio C Hamano 已提交
387
link:git-parse-remote.html[git-parse-remote]::
J
Junio C Hamano 已提交
388
	Routines to help parsing $GIT_DIR/remotes/
J
Junio C Hamano 已提交
389
	Previously this command was known as git-parse-remote-script.
J
Junio C Hamano 已提交
390

J
Junio C Hamano 已提交
391 392 393
link:git-request-pull.html[git-request-pull]::
	git-request-pull.
	Previously this command was known as git-request-pull-script.
J
Junio C Hamano 已提交
394 395 396 397

link:git-rev-parse.html[git-rev-parse]::
	Pick out and massage parameters.

J
Junio C Hamano 已提交
398
link:git-send-email.html[git-send-email]::
399
	Send patch e-mails out of "format-patch --mbox" output.
J
Junio C Hamano 已提交
400
	Previously this command was known as git-send-email-script.
401

J
Junio C Hamano 已提交
402 403 404
link:git-show-rev-cache.html[git-show-rev-cache]::
	Show the contents of a rev-cache file.

J
Junio C Hamano 已提交
405 406
link:git-stripspace.html[git-stripspace]::
	Filter out empty lines.
407 408


J
Junio C Hamano 已提交
409 410
Commands not yet documented
---------------------------
411 412 413 414 415

link:gitk.html[gitk]::
	gitk.


416
Identifier Terminology
417 418
----------------------
<object>::
419
	Indicates the sha1 identifier for any type of object
420 421 422 423 424 425 426 427 428 429 430

<blob>::
	Indicates a blob object sha1 identifier

<tree>::
	Indicates a tree object sha1 identifier

<commit>::
	Indicates a commit object sha1 identifier

<tree-ish>::
431 432 433 434
	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>.
435 436 437 438 439 440 441 442 443

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

444 445
Symbolic Identifiers
--------------------
446
Any git command accepting any <object> can also use the following
447
symbolic notation:
448 449

HEAD::
450 451
	indicates the head of the repository (ie the contents of
	`$GIT_DIR/HEAD`)
452 453 454 455 456 457 458 459 460 461 462 463 464 465
<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 已提交
466
Please see link:repository-layout.html[repository layout] document.
467 468 469 470

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

J
Junio C Hamano 已提交
471

472 473
Terminology
-----------
474
Please see link:glossary.html[glossary] document.
475 476 477 478 479 480


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

481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
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
501
	specifies a ":" separated list of git object directories which
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520
	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'::
	see link:git-commit-tree.html[git-commit-tree]

git Diffs
~~~~~~~~~
521 522
'GIT_DIFF_OPTS'::
'GIT_EXTERNAL_DIFF'::
523
	see the "generating patches" section in :
J
Junio C Hamano 已提交
524
	link:git-diff-index.html[git-diff-index];
525 526
	link:git-diff-files.html[git-diff-files];
	link:git-diff-tree.html[git-diff-tree]
527

J
Junio C Hamano 已提交
528 529
Discussion[[Discussion]]
------------------------
530 531
include::../README[]

532 533
Author
------
534
Written by Linus Torvalds <torvalds@osdl.org> and the git-list <git@vger.kernel.org>.
535 536 537 538 539 540 541 542 543

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

GIT
---
Part of the link:git.html[git] suite