Merge branch 'bg/maint-add-all-doc' into maint-1.6.5
* bg/maint-add-all-doc: git-rm doc: Describe how to sync index & work tree git-add/rm doc: Consistently back-quote Documentation: 'git add -A' can remove files
This commit is contained in:
commit
4b683658be
@ -14,28 +14,32 @@ SYNOPSIS
|
|||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
This command adds the current content of new or modified files to the
|
This command updates the index using the current content found in
|
||||||
index, thus staging that content for inclusion in the next commit.
|
the working tree, to prepare the content staged for the next commit.
|
||||||
|
It typically adds the current content of existing paths as a whole,
|
||||||
|
but with some options it can also be used to add content with
|
||||||
|
only part of the changes made to the working tree files applied, or
|
||||||
|
remove paths that do not exist in the working tree anymore.
|
||||||
|
|
||||||
The "index" holds a snapshot of the content of the working tree, and it
|
The "index" holds a snapshot of the content of the working tree, and it
|
||||||
is this snapshot that is taken as the contents of the next commit. Thus
|
is this snapshot that is taken as the contents of the next commit. Thus
|
||||||
after making any changes to the working directory, and before running
|
after making any changes to the working directory, and before running
|
||||||
the commit command, you must use the 'add' command to add any new or
|
the commit command, you must use the `add` command to add any new or
|
||||||
modified files to the index.
|
modified files to the index.
|
||||||
|
|
||||||
This command can be performed multiple times before a commit. It only
|
This command can be performed multiple times before a commit. It only
|
||||||
adds the content of the specified file(s) at the time the add command is
|
adds the content of the specified file(s) at the time the add command is
|
||||||
run; if you want subsequent changes included in the next commit, then
|
run; if you want subsequent changes included in the next commit, then
|
||||||
you must run 'git add' again to add the new content to the index.
|
you must run `git add` again to add the new content to the index.
|
||||||
|
|
||||||
The 'git status' command can be used to obtain a summary of which
|
The `git status` command can be used to obtain a summary of which
|
||||||
files have changes that are staged for the next commit.
|
files have changes that are staged for the next commit.
|
||||||
|
|
||||||
The 'git add' command will not add ignored files by default. If any
|
The `git add` command will not add ignored files by default. If any
|
||||||
ignored files were explicitly specified on the command line, 'git add'
|
ignored files were explicitly specified on the command line, `git add`
|
||||||
will fail with a list of ignored files. Ignored files reached by
|
will fail with a list of ignored files. Ignored files reached by
|
||||||
directory recursion or filename globbing performed by Git (quote your
|
directory recursion or filename globbing performed by Git (quote your
|
||||||
globs before the shell) will be silently ignored. The 'add' command can
|
globs before the shell) will be silently ignored. The `add` command can
|
||||||
be used to add ignored files with the `-f` (force) option.
|
be used to add ignored files with the `-f` (force) option.
|
||||||
|
|
||||||
Please see linkgit:git-commit[1] for alternative ways to add content to a
|
Please see linkgit:git-commit[1] for alternative ways to add content to a
|
||||||
@ -92,28 +96,31 @@ apply.
|
|||||||
|
|
||||||
-u::
|
-u::
|
||||||
--update::
|
--update::
|
||||||
Update only files that git already knows about, staging modified
|
Only match <filepattern> against already tracked files in
|
||||||
content for commit and marking deleted files for removal. This
|
the index rather than the working tree. That means that it
|
||||||
is similar
|
will never stage new files, but that it will stage modified
|
||||||
to what "git commit -a" does in preparation for making a commit,
|
new contents of tracked files and that it will remove files
|
||||||
except that the update is limited to paths specified on the
|
from the index if the corresponding files in the working tree
|
||||||
command line. If no paths are specified, all tracked files in the
|
have been removed.
|
||||||
current directory and its subdirectories are updated.
|
+
|
||||||
|
If no <filepattern> is given, default to "."; in other words,
|
||||||
|
update all tracked files in the current directory and its
|
||||||
|
subdirectories.
|
||||||
|
|
||||||
-A::
|
-A::
|
||||||
--all::
|
--all::
|
||||||
Update files that git already knows about (same as '\--update')
|
Like `-u`, but match <filepattern> against files in the
|
||||||
and add all untracked files that are not ignored by '.gitignore'
|
working tree in addition to the index. That means that it
|
||||||
mechanism.
|
will find new files as well as staging modified content and
|
||||||
|
removing files that are no longer in the working tree.
|
||||||
|
|
||||||
-N::
|
-N::
|
||||||
--intent-to-add::
|
--intent-to-add::
|
||||||
Record only the fact that the path will be added later. An entry
|
Record only the fact that the path will be added later. An entry
|
||||||
for the path is placed in the index with no content. This is
|
for the path is placed in the index with no content. This is
|
||||||
useful for, among other things, showing the unstaged content of
|
useful for, among other things, showing the unstaged content of
|
||||||
such files with 'git diff' and committing them with 'git commit
|
such files with `git diff` and committing them with `git commit
|
||||||
-a'.
|
-a`.
|
||||||
|
|
||||||
--refresh::
|
--refresh::
|
||||||
Don't add the file(s), but only refresh their stat()
|
Don't add the file(s), but only refresh their stat()
|
||||||
@ -133,7 +140,7 @@ apply.
|
|||||||
Configuration
|
Configuration
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
The optional configuration variable 'core.excludesfile' indicates a path to a
|
The optional configuration variable `core.excludesfile` indicates a path to a
|
||||||
file containing patterns of file names to exclude from git-add, similar to
|
file containing patterns of file names to exclude from git-add, similar to
|
||||||
$GIT_DIR/info/exclude. Patterns in the exclude file are used in addition to
|
$GIT_DIR/info/exclude. Patterns in the exclude file are used in addition to
|
||||||
those in info/exclude. See linkgit:gitrepository-layout[5].
|
those in info/exclude. See linkgit:gitrepository-layout[5].
|
||||||
@ -181,7 +188,7 @@ and type return, like this:
|
|||||||
What now> 1
|
What now> 1
|
||||||
------------
|
------------
|
||||||
|
|
||||||
You also could say "s" or "sta" or "status" above as long as the
|
You also could say `s` or `sta` or `status` above as long as the
|
||||||
choice is unique.
|
choice is unique.
|
||||||
|
|
||||||
The main command loop has 6 subcommands (plus help and quit).
|
The main command loop has 6 subcommands (plus help and quit).
|
||||||
@ -189,9 +196,9 @@ The main command loop has 6 subcommands (plus help and quit).
|
|||||||
status::
|
status::
|
||||||
|
|
||||||
This shows the change between HEAD and index (i.e. what will be
|
This shows the change between HEAD and index (i.e. what will be
|
||||||
committed if you say "git commit"), and between index and
|
committed if you say `git commit`), and between index and
|
||||||
working tree files (i.e. what you could stage further before
|
working tree files (i.e. what you could stage further before
|
||||||
"git commit" using "git-add") for each path. A sample output
|
`git commit` using `git add`) for each path. A sample output
|
||||||
looks like this:
|
looks like this:
|
||||||
+
|
+
|
||||||
------------
|
------------
|
||||||
|
@ -12,13 +12,13 @@ SYNOPSIS
|
|||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
Remove files from the index, or from the working tree and the index.
|
Remove files from the index, or from the working tree and the index.
|
||||||
'git-rm' will not remove a file from just your working directory.
|
`git rm` will not remove a file from just your working directory.
|
||||||
(There is no option to remove a file only from the work tree
|
(There is no option to remove a file only from the working tree
|
||||||
and yet keep it in the index; use `/bin/rm` if you want to do that.)
|
and yet keep it in the index; use `/bin/rm` if you want to do that.)
|
||||||
The files being removed have to be identical to the tip of the branch,
|
The files being removed have to be identical to the tip of the branch,
|
||||||
and no updates to their contents can be staged in the index,
|
and no updates to their contents can be staged in the index,
|
||||||
though that default behavior can be overridden with the `-f` option.
|
though that default behavior can be overridden with the `-f` option.
|
||||||
When '--cached' is given, the staged content has to
|
When `--cached` is given, the staged content has to
|
||||||
match either the tip of the branch or the file on disk,
|
match either the tip of the branch or the file on disk,
|
||||||
allowing the file to be removed from just the index.
|
allowing the file to be removed from just the index.
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ OPTIONS
|
|||||||
|
|
||||||
-q::
|
-q::
|
||||||
--quiet::
|
--quiet::
|
||||||
'git-rm' normally outputs one line (in the form of an "rm" command)
|
`git rm` normally outputs one line (in the form of an `rm` command)
|
||||||
for each file removed. This option suppresses that output.
|
for each file removed. This option suppresses that output.
|
||||||
|
|
||||||
|
|
||||||
@ -81,6 +81,58 @@ two directories `d` and `d2`, there is a difference between
|
|||||||
using `git rm \'d\*\'` and `git rm \'d/\*\'`, as the former will
|
using `git rm \'d\*\'` and `git rm \'d/\*\'`, as the former will
|
||||||
also remove all of directory `d2`.
|
also remove all of directory `d2`.
|
||||||
|
|
||||||
|
REMOVING FILES THAT HAVE DISAPPEARED FROM THE FILESYSTEM
|
||||||
|
--------------------------------------------------------
|
||||||
|
There is no option for `git rm` to remove from the index only
|
||||||
|
the paths that have disappeared from the filesystem. However,
|
||||||
|
depending on the use case, there are several ways that can be
|
||||||
|
done.
|
||||||
|
|
||||||
|
Using "git commit -a"
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
If you intend that your next commit should record all modifications
|
||||||
|
of tracked files in the working tree and record all removals of
|
||||||
|
files that have been removed from the working tree with `rm`
|
||||||
|
(as opposed to `git rm`), use `git commit -a`, as it will
|
||||||
|
automatically notice and record all removals. You can also have a
|
||||||
|
similar effect without committing by using `git add -u`.
|
||||||
|
|
||||||
|
Using "git add -A"
|
||||||
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
When accepting a new code drop for a vendor branch, you probably
|
||||||
|
want to record both the removal of paths and additions of new paths
|
||||||
|
as well as modifications of existing paths.
|
||||||
|
|
||||||
|
Typically you would first remove all tracked files from the working
|
||||||
|
tree using this command:
|
||||||
|
|
||||||
|
----------------
|
||||||
|
git ls-files -z | xargs -0 rm -f
|
||||||
|
----------------
|
||||||
|
|
||||||
|
and then "untar" the new code in the working tree. Alternately
|
||||||
|
you could "rsync" the changes into the working tree.
|
||||||
|
|
||||||
|
After that, the easiest way to record all removals, additions, and
|
||||||
|
modifications in the working tree is:
|
||||||
|
|
||||||
|
----------------
|
||||||
|
git add -A
|
||||||
|
----------------
|
||||||
|
|
||||||
|
See linkgit:git-add[1].
|
||||||
|
|
||||||
|
Other ways
|
||||||
|
~~~~~~~~~~
|
||||||
|
If all you really want to do is to remove from the index the files
|
||||||
|
that are no longer present in the working tree (perhaps because
|
||||||
|
your working tree is dirty so that you cannot use `git commit -a`),
|
||||||
|
use the following command:
|
||||||
|
|
||||||
|
----------------
|
||||||
|
git diff --name-only --diff-filter=D -z | xargs -0 git rm --cached
|
||||||
|
----------------
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
--------
|
--------
|
||||||
git rm Documentation/\\*.txt::
|
git rm Documentation/\\*.txt::
|
||||||
|
Loading…
Reference in New Issue
Block a user