forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 155
doc: git-add: clarify DESCRIPTION section #1952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jvns
wants to merge
2
commits into
gitgitgadget:master
Choose a base branch
from
jvns:clarify-add
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,18 +16,18 @@ git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [- | |
|
||
DESCRIPTION | ||
----------- | ||
This command updates the index using the current content found in | ||
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 | ||
is this snapshot that is taken as the contents of the next commit. Thus | ||
after making any changes to the working tree, and before running | ||
the commit command, you must use the `add` command to add any new or | ||
modified files to the index. | ||
Add contents of new or changed files to the index. The "index" (also | ||
known as "staging area") is where Git stores the contents of the next | ||
commit. | ||
|
||
When you run `git commit` without any other arguments, it will only | ||
commit staged changes. For example, if you've edited `file.c` and want | ||
to commit your changes to that file, you can run: | ||
|
||
git add file.c | ||
git commit | ||
|
||
You can also add only part of your changes to a file with `git add -p`. | ||
|
||
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 | ||
|
@@ -37,12 +37,10 @@ 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): "Julia Evans via GitGitGadget" <[email protected]> writes:
> -The `git add` command will not add ignored files by default. If any
> -ignored files were explicitly specified on the command line, `git add`
> -will fail with a list of ignored files. Ignored files reached by
> -directory recursion or filename globbing performed by Git (quote your
> -globs before the shell) will be silently ignored. The `git add` command can
> -be used to add ignored files with the `-f` (force) option.
> +`git add` will not add ignored files by default. You can use the
> +`--force` option to add ignored files. If you explicitly specify the
> +exact filename of an ignored file (e.g. `git add ignored.txt`), `git
> +add` will fail with a list of ignored files. Otherwise it will silently
> +ignore the file.
I think we no longer need to say "explicitly" now that we added
"exact".
The earlier text used "explicitly" because it wanted to say that
"git add t/ 'ig*.txt'" silently ignores "t/ignored-file.txt" and
"ignored-file.txt" because these files are not explicitly named
(they were only implicitly named via recursion or globbing). Your
new wording "exact filename" already covers these cases.
Do we discuss that "git add t/" attempts to add everything that is
not ignored under the t/ directory elsewhere in this document after
these patches? If we do, then I am 100% OK with the decision to
stop talking about globs and recursion in this paragraph. Otherwise,
I would want to see some mention of this "naming directory names its
contents recursively" somewhere in the document (it does not have to
be, but can naturally be, in this paragraph).
Thanks.
|
||
files have changes that are staged for the next commit. | ||
|
||
The `git add` command will not add ignored files by default. If any | ||
ignored files were explicitly specified on the command line, `git add` | ||
will fail with a list of ignored files. Ignored files reached by | ||
directory recursion or filename globbing performed by Git (quote your | ||
globs before the shell) will be silently ignored. The `git add` command can | ||
be used to add ignored files with the `-f` (force) option. | ||
The `git add` command will not add ignored files by default. You can | ||
use the `--force` option to add ignored files. If you specify the exact | ||
filename of an ignored file, `git add` will fail with a list of ignored | ||
files. Otherwise it will silently ignore the file. | ||
|
||
Please see linkgit:git-commit[1] for alternative ways to add content to a | ||
commit. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, "D. Ben Knoble" wrote (reply to this):