index c5d5596d895755d69c8060bc38a800d7c70eda26..dee050567e65301066629c566613b84c6c065169 100644 (file)
SYNOPSIS
--------
SYNOPSIS
--------
+[verse]
git *
DESCRIPTION
git *
DESCRIPTION
directory created, named ".git".
Next, tell git to take a snapshot of the contents of all files under the
directory created, named ".git".
Next, tell git to take a snapshot of the contents of all files under the
-current directory (note the '.'), with 'git-add':
+current directory (note the '.'), with 'git add':
------------------------------------------------
$ git add .
------------------------------------------------
$ git add .
This snapshot is now stored in a temporary staging area which git calls
the "index". You can permanently store the contents of the index in the
This snapshot is now stored in a temporary staging area which git calls
the "index". You can permanently store the contents of the index in the
-repository with 'git-commit':
+repository with 'git commit':
------------------------------------------------
$ git commit
------------------------------------------------
$ git commit
------------------------------------------------
You are now ready to commit. You can see what is about to be committed
------------------------------------------------
You are now ready to commit. You can see what is about to be committed
-using 'git-diff' with the --cached option:
+using 'git diff' with the --cached option:
------------------------------------------------
$ git diff --cached
------------------------------------------------
------------------------------------------------
$ git diff --cached
------------------------------------------------
-(Without --cached, 'git-diff' will show you any changes that
+(Without --cached, 'git diff' will show you any changes that
you've made but not yet added to the index.) You can also get a brief
you've made but not yet added to the index.) You can also get a brief
-summary of the situation with 'git-status':
+summary of the situation with 'git status':
------------------------------------------------
$ git status
------------------------------------------------
$ git status
This will again prompt you for a message describing the change, and then
record a new version of the project.
This will again prompt you for a message describing the change, and then
record a new version of the project.
-Alternatively, instead of running 'git-add' beforehand, you can use
+Alternatively, instead of running 'git add' beforehand, you can use
------------------------------------------------
$ git commit -a
------------------------------------------------
$ git commit -a
Many revision control systems provide an `add` command that tells the
system to start tracking changes to a new file. Git's `add` command
Many revision control systems provide an `add` command that tells the
system to start tracking changes to a new file. Git's `add` command
-does something simpler and more powerful: 'git-add' is used both for new
+does something simpler and more powerful: 'git add' is used both for new
and newly modified files, and in both cases it takes a snapshot of the
given files and stages that content in the index, ready for inclusion in
the next commit.
and newly modified files, and in both cases it takes a snapshot of the
given files and stages that content in the index, ready for inclusion in
the next commit.
------------------------------------------------
This operation is safe even if Alice has uncommitted local changes.
------------------------------------------------
This operation is safe even if Alice has uncommitted local changes.
-The range notation HEAD..FETCH_HEAD" means "show everything that is reachable
-from the FETCH_HEAD but exclude anything that is reachable from HEAD.
+The range notation "HEAD..FETCH_HEAD" means "show everything that is reachable
+from the FETCH_HEAD but exclude anything that is reachable from HEAD".
Alice already knows everything that leads to her current state (HEAD),
Alice already knows everything that leads to her current state (HEAD),
-and reviewing what Bob has in his state (FETCH_HEAD) that she has not
-seen with this command
+and reviews what Bob has in his state (FETCH_HEAD) that she has not
+seen with this command.
If Alice wants to visualize what Bob did since their histories forked
she can issue the following command:
If Alice wants to visualize what Bob did since their histories forked
she can issue the following command:
alice$ git remote add bob /home/bob/myrepo
------------------------------------------------
alice$ git remote add bob /home/bob/myrepo
------------------------------------------------
-With this, Alice can perform the first part of the "pull" operation alone using the
-'git-fetch' command without merging them with her own branch,
-using:
+With this, Alice can perform the first part of the "pull" operation
+alone using the 'git fetch' command without merging them with her own
+branch, using:
-------------------------------------
alice$ git fetch bob
-------------------------------------
Unlike the longhand form, when Alice fetches from Bob using a
-------------------------------------
alice$ git fetch bob
-------------------------------------
Unlike the longhand form, when Alice fetches from Bob using a
-remote repository shorthand set up with 'git-remote', what was
-fetched is stored in a remote tracking branch, in this case
+remote repository shorthand set up with 'git remote', what was
+fetched is stored in a remote-tracking branch, in this case
`bob/master`. So after this:
-------------------------------------
`bob/master`. So after this:
-------------------------------------
alice$ git merge bob/master
-------------------------------------
alice$ git merge bob/master
-------------------------------------
-This `merge` can also be done by 'pulling from her own remote
-tracking branch', like this:
+This `merge` can also be done by 'pulling from her own remote-tracking
+branch', like this:
-------------------------------------
alice$ git pull . remotes/bob/master
-------------------------------------
alice$ git pull . remotes/bob/master
/home/alice/project
-------------------------------------
/home/alice/project
-------------------------------------
-(The complete configuration created by 'git-clone' is visible using
+(The complete configuration created by 'git clone' is visible using
`git config -l`, and the linkgit:git-config[1] man page
explains the meaning of each option.)
`git config -l`, and the linkgit:git-config[1] man page
explains the meaning of each option.)
-----------------
Git history is represented as a series of interrelated commits. We
-----------------
Git history is represented as a series of interrelated commits. We
-have already seen that the 'git-log' command can list those commits.
+have already seen that the 'git log' command can list those commits.
Note that first line of each git log entry also gives a name for the
commit:
Note that first line of each git log entry also gives a name for the
commit:
merge-base: Clarify the comments on post processing.
-------------------------------------
merge-base: Clarify the comments on post processing.
-------------------------------------
-We can give this name to 'git-show' to see the details about this
+We can give this name to 'git show' to see the details about this
commit.
-------------------------------------
commit.
-------------------------------------
Be careful with that last command: in addition to losing any changes
in the working directory, it will also remove all later commits from
this branch. If this branch is the only branch containing those
Be careful with that last command: in addition to losing any changes
in the working directory, it will also remove all later commits from
this branch. If this branch is the only branch containing those
-commits, they will be lost. Also, don't use 'git-reset' on a
+commits, they will be lost. Also, don't use 'git reset' on a
publicly-visible branch that other developers pull from, as it will
force needless merges on other developers to clean up the history.
publicly-visible branch that other developers pull from, as it will
force needless merges on other developers to clean up the history.
-If you need to undo changes that you have pushed, use 'git-revert'
+If you need to undo changes that you have pushed, use 'git revert'
instead.
instead.
-The 'git-grep' command can search for strings in any version of your
+The 'git grep' command can search for strings in any version of your
project, so
-------------------------------------
project, so
-------------------------------------
searches for all occurrences of "hello" in v2.5.
searches for all occurrences of "hello" in v2.5.
-If you leave out the commit name, 'git-grep' will search any of the
+If you leave out the commit name, 'git grep' will search any of the
files it manages in your current directory. So
-------------------------------------
files it manages in your current directory. So
-------------------------------------
is a quick way to search just the files that are tracked by git.
Many git commands also take sets of commits, which can be specified
is a quick way to search just the files that are tracked by git.
Many git commands also take sets of commits, which can be specified
-in a number of ways. Here are some examples with 'git-log':
+in a number of ways. Here are some examples with 'git log':
-------------------------------------
$ git log v2.5..v2.6 # commits between v2.5 and v2.6
-------------------------------------
$ git log v2.5..v2.6 # commits between v2.5 and v2.6
# Makefile
-------------------------------------
# Makefile
-------------------------------------
-You can also give 'git-log' a "range" of commits where the first is not
+You can also give 'git log' a "range" of commits where the first is not
necessarily an ancestor of the second; for example, if the tips of
necessarily an ancestor of the second; for example, if the tips of
-the branches "stable-release" and "master" diverged from a common
+the branches "stable" and "master" diverged from a common
commit some time ago, then
-------------------------------------
commit some time ago, then
-------------------------------------
-$ git log stable..experimental
+$ git log stable..master
-------------------------------------
-------------------------------------
-will list commits made in the experimental branch but not in the
+will list commits made in the master branch but not in the
stable branch, while
-------------------------------------
stable branch, while
-------------------------------------
-$ git log experimental..stable
+$ git log master..stable
-------------------------------------
will show the list of commits made on the stable branch but not
-------------------------------------
will show the list of commits made on the stable branch but not
-the experimental branch.
+the master branch.
-The 'git-log' command has a weakness: it must present commits in a
+The 'git log' command has a weakness: it must present commits in a
list. When the history has lines of development that diverged and
list. When the history has lines of development that diverged and
-then merged back together, the order in which 'git-log' presents
+then merged back together, the order in which 'git log' presents
those commits is meaningless.
Most projects with multiple contributors (such as the Linux kernel,
those commits is meaningless.
Most projects with multiple contributors (such as the Linux kernel,
$ git diff v2.5:Makefile HEAD:Makefile.in
-------------------------------------
$ git diff v2.5:Makefile HEAD:Makefile.in
-------------------------------------
-You can also use 'git-show' to see any such file:
+You can also use 'git show' to see any such file:
-------------------------------------
$ git show v2.5:Makefile
-------------------------------------
$ git show v2.5:Makefile
smart enough to perform a close-to-optimal search even in the
case of complex non-linear history with lots of merged branches.
smart enough to perform a close-to-optimal search even in the
case of complex non-linear history with lots of merged branches.
+ * linkgit:gitworkflows[7]: Gives an overview of recommended
+ workflows.
+
* link:everyday.html[Everyday GIT with 20 Commands Or So]
* linkgit:gitcvs-migration[7]: Git for CVS users.
* link:everyday.html[Everyday GIT with 20 Commands Or So]
* linkgit:gitcvs-migration[7]: Git for CVS users.
linkgit:gitcore-tutorial[7],
linkgit:gitglossary[7],
linkgit:git-help[1],
linkgit:gitcore-tutorial[7],
linkgit:gitglossary[7],
linkgit:git-help[1],
+linkgit:gitworkflows[7],
link:everyday.html[Everyday git],
link:user-manual.html[The Git User's Manual]
link:everyday.html[Everyday git],
link:user-manual.html[The Git User's Manual]