git.txt 12.9 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
the repository, the index and the working fileset, those that
44 45
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 index to the working directory
63

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

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

S
Sergey Vlasov 已提交
70 71 72
gitlink:git-index-pack.html[1]::
	Build pack index file for an existing packed archive.

73
gitlink:git-init-db[1]::
74 75
	Creates an empty git object database

76
gitlink:git-merge-index[1]::
77
	Runs a merge for files needing merging
78

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

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

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

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

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

94
gitlink:git-update-index[1]::
95 96
	Modifies the index or directory cache

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

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 index and repository
109

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

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

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

119
gitlink:git-fsck-objects[1]::
120 121
	Verifies the connectivity and validity of the objects in the database

122
gitlink:git-ls-files[1]::
123
	Information about files in the index/working directory
124

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

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

131 132 133
gitlink:git-name-rev[1]::
	Find symbolic names for given revs

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

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

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

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

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

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

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


156 157 158
Synching repositories
~~~~~~~~~~~~~~~~~~~~~

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

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

166
gitlink:git-http-fetch[1]::
167
	Downloads a remote git repository via HTTP
168

169
gitlink:git-local-fetch[1]::
170
	Duplicates another git repository on a local system
171

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

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

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

P
Petr Baudis 已提交
181 182 183
gitlink:git-shell[1]::
	Restricted shell for GIT-only SSH access.

184
gitlink:git-ssh-fetch[1]::
185
	Pulls from a remote repository over ssh connection
186

187
gitlink:git-ssh-upload[1]::
J
Junio C Hamano 已提交
188
	Helper "server-side" program used by git-ssh-fetch
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 204
	Add paths to the index file.

205 206 207
gitlink:git-am[1]::
	Apply patches from a mailbox, but cooler.

208
gitlink:git-applymbox[1]::
209 210
	Apply patches from a mailbox.

211
gitlink:git-bisect[1]::
212 213
	Find the change that introduced a bug.

214
gitlink:git-branch[1]::
215 216
	Create and Show branches.

217
gitlink:git-checkout[1]::
J
Junio C Hamano 已提交
218 219
	Checkout and switch to a branch.

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

223
gitlink:git-clone[1]::
224
	Clones a repository into a new directory.
J
Junio C Hamano 已提交
225

226
gitlink:git-commit[1]::
227
	Record changes to the repository.
J
Junio C Hamano 已提交
228

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

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

235
gitlink:git-format-patch[1]::
236
	Prepare patches for e-mail submission.
J
Junio C Hamano 已提交
237

238
gitlink:git-grep[1]::
239 240
	Print lines matching a pattern

241
gitlink:git-log[1]::
242
	Shows commit logs.
J
Junio C Hamano 已提交
243

244
gitlink:git-ls-remote[1]::
245
	Shows references in a remote or local repository.
246

247
gitlink:git-merge[1]::
J
Junio C Hamano 已提交
248 249
	Grand unified merge driver.

250 251 252
gitlink:git-mv[1]::
	Move or rename a file, a directory, or a symlink.

253
gitlink:git-octopus[1]::
254 255
	Merge more than two commits.

256
gitlink:git-pull[1]::
257 258
	Fetch from and merge with a remote repository.

259
gitlink:git-push[1]::
260 261
	Update remote refs along with associated objects.

262
gitlink:git-rebase[1]::
263
	Rebase local commits to new upstream head.
J
Junio C Hamano 已提交
264

265
gitlink:git-rename[1]::
266
	Rename files and directories.
J
Junio C Hamano 已提交
267

268
gitlink:git-repack[1]::
269 270
	Pack unpacked objects in a repository.

271
gitlink:git-reset[1]::
J
Junio C Hamano 已提交
272 273
	Reset current HEAD to the specified state.

274
gitlink:git-resolve[1]::
275
	Merge two commits.
276

277
gitlink:git-revert[1]::
278 279
	Revert an existing commit.

280
gitlink:git-shortlog[1]::
281 282
	Summarizes 'git log' output.

283
gitlink:git-show-branch[1]::
284 285
	Show branches and their commits.

286
gitlink:git-status[1]::
287
	Shows the working tree status.
288

289
gitlink:git-verify-tag[1]::
290 291
	Check the GPG signature of tag.

292
gitlink:git-whatchanged[1]::
293 294
	Shows commit logs and differences they introduce.

295

296 297
Ancillary Commands
------------------
298 299
Manipulators:

300
gitlink:git-applypatch[1]::
301
	Apply one patch extracted from an e-mail.
302

303
gitlink:git-archimport[1]::
J
Junio C Hamano 已提交
304 305
	Import an arch repository into git.

306
gitlink:git-convert-objects[1]::
307
	Converts old-style git repository
308

309
gitlink:git-cvsimport[1]::
310 311
	Salvage your data out of another SCM people love to hate.

J
Junio C Hamano 已提交
312 313 314
gitlink:git-lost+found[1]::
	Recover lost refs that luckily have not yet been pruned.

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

318
gitlink:git-prune[1]::
319 320
	Prunes all unreachable objects from the object database

321
gitlink:git-relink[1]::
322 323
	Hardlink common objects in local repositories.

324 325 326
gitlink:git-svnimport[1]::
	Import a SVN repository into git.

327
gitlink:git-sh-setup[1]::
328 329
	Common git shell script setup code.

330 331 332
gitlink:git-symbolic-ref[1]::
	Read and modify symbolic refs

333
gitlink:git-tag[1]::
334 335
	An example script to create a tag object signed with GPG

336 337 338
gitlink:git-update-ref[1]::
	Update the object name stored in a ref safely.

339

340
Interrogators:
341

342 343 344
gitlink:git-check-ref-format[1]::
	Make sure ref name is well formed.

345
gitlink:git-cherry[1]::
346
	Find commits not merged upstream.
347

348
gitlink:git-count-objects[1]::
349 350
	Count unpacked number of objects and their disk consumption.

351
gitlink:git-daemon[1]::
352
	A really simple server for git repositories.
J
Junio C Hamano 已提交
353

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

357
gitlink:git-mailinfo[1]::
358 359
	Extracts patch from a single e-mail message.

360
gitlink:git-mailsplit[1]::
361 362
	git-mailsplit.

363
gitlink:git-patch-id[1]::
364
	Compute unique ID for a patch.
365

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

369
gitlink:git-request-pull[1]::
J
Junio C Hamano 已提交
370
	git-request-pull.
J
Junio C Hamano 已提交
371

372
gitlink:git-rev-parse[1]::
J
Junio C Hamano 已提交
373 374
	Pick out and massage parameters.

375
gitlink:git-send-email[1]::
376
	Send patch e-mails out of "format-patch --mbox" output.
377

378 379 380
gitlink:git-symbolic-refs[1]::
	Read and modify symbolic refs.

381
gitlink:git-stripspace[1]::
J
Junio C Hamano 已提交
382
	Filter out empty lines.
383 384


J
Junio C Hamano 已提交
385 386
Commands not yet documented
---------------------------
387

388
gitlink:gitk[1]::
389 390 391
	gitk.


J
Junio C Hamano 已提交
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
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.


423
Identifier Terminology
424 425
----------------------
<object>::
426
	Indicates the sha1 identifier for any type of object
427 428 429 430 431 432 433 434 435 436 437

<blob>::
	Indicates a blob object sha1 identifier

<tree>::
	Indicates a tree object sha1 identifier

<commit>::
	Indicates a commit object sha1 identifier

<tree-ish>::
438 439 440 441
	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>.
442 443 444 445 446 447 448 449 450

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

451 452
Symbolic Identifiers
--------------------
453
Any git command accepting any <object> can also use the following
454
symbolic notation:
455 456

HEAD::
457 458
	indicates the head of the repository (ie the contents of
	`$GIT_DIR/HEAD`)
459 460 461 462 463 464 465 466 467 468 469 470 471 472
<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 已提交
473
Please see link:repository-layout.html[repository layout] document.
474 475 476 477

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

J
Junio C Hamano 已提交
478

479 480
Terminology
-----------
481
Please see link:glossary.html[glossary] document.
482 483 484 485 486 487


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

488 489 490 491 492 493 494 495
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
496 497
	index file. If not specified, the default of `$GIT_DIR/index`
	is used.
498 499 500 501 502 503 504 505 506 507

'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
508
	specifies a ":" separated list of git object directories which
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523
	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'::
524
	see gitlink:git-commit-tree[1]
525 526 527

git Diffs
~~~~~~~~~
528 529
'GIT_DIFF_OPTS'::
'GIT_EXTERNAL_DIFF'::
530
	see the "generating patches" section in :
531 532 533
	gitlink:git-diff-index[1];
	gitlink:git-diff-files[1];
	gitlink:git-diff-tree[1]
534

J
Junio C Hamano 已提交
535 536
Discussion[[Discussion]]
------------------------
537 538
include::../README[]

539 540
Author
------
541
Written by Linus Torvalds <torvalds@osdl.org> and the git-list <git@vger.kernel.org>.
542 543 544 545 546 547 548

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

GIT
---
549
Part of the gitlink:git[7] suite
550