-
Notifications
You must be signed in to change notification settings - Fork 141
Support --pathspec-from-file in rm, stash #530
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
Changes from all commits
cf065e9
7c657de
bb30021
fdaf453
764b866
7353b06
d34eaf4
6465a29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,16 +8,18 @@ git-rm - Remove files from the working tree and from the index | |
SYNOPSIS | ||
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):
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, Alexandr Miloslavskiy wrote (reply to this):
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):
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, Alexandr Miloslavskiy wrote (reply to this):
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):
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, Alexandr Miloslavskiy wrote (reply to this):
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):
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):
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, Alexandr Miloslavskiy wrote (reply to this):
|
||
-------- | ||
[verse] | ||
'git rm' [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch] [--quiet] [--] <file>... | ||
'git rm' [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch] | ||
[--quiet] [--pathspec-from-file=<file> [--pathspec-file-nul]] | ||
[--] [<pathspec>...] | ||
|
||
DESCRIPTION | ||
----------- | ||
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. | ||
(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.) | ||
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, | ||
Remove files matching pathspec from the index, or from the working tree | ||
and the index. `git rm` will not remove a file from just your working | ||
directory. (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.) 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, | ||
though that default behavior can be overridden with the `-f` option. | ||
When `--cached` is given, the staged content has to | ||
match either the tip of the branch or the file on disk, | ||
|
@@ -26,15 +28,20 @@ allowing the file to be removed from just the index. | |
|
||
OPTIONS | ||
------- | ||
<file>...:: | ||
Files to remove. Fileglobs (e.g. `*.c`) can be given to | ||
remove all matching files. If you want Git to expand | ||
file glob characters, you may need to shell-escape them. | ||
A leading directory name | ||
(e.g. `dir` to remove `dir/file1` and `dir/file2`) can be | ||
given to remove all files in the directory, and recursively | ||
all sub-directories, | ||
but this requires the `-r` option to be explicitly given. | ||
<pathspec>...:: | ||
Files to remove. A leading directory name (e.g. `dir` to remove | ||
`dir/file1` and `dir/file2`) can be given to remove all files in | ||
the directory, and recursively all sub-directories, but this | ||
requires the `-r` option to be explicitly given. | ||
+ | ||
The command removes only the paths that are known to Git. | ||
+ | ||
File globbing matches across directory boundaries. Thus, given two | ||
directories `d` and `d2`, there is a difference between using | ||
`git rm 'd*'` and `git rm 'd/*'`, as the former will also remove all | ||
of directory `d2`. | ||
+ | ||
For more details, see the 'pathspec' entry in linkgit:gitglossary[7]. | ||
|
||
-f:: | ||
--force:: | ||
|
@@ -68,19 +75,19 @@ OPTIONS | |
`git rm` normally outputs one line (in the form of an `rm` command) | ||
for each file removed. This option suppresses that output. | ||
|
||
--pathspec-from-file=<file>:: | ||
Pathspec is passed in `<file>` instead of commandline args. If | ||
`<file>` is exactly `-` then standard input is used. Pathspec | ||
elements are separated by LF or CR/LF. Pathspec elements can be | ||
quoted as explained for the configuration variable `core.quotePath` | ||
(see linkgit:git-config[1]). See also `--pathspec-file-nul` and | ||
global `--literal-pathspecs`. | ||
|
||
DISCUSSION | ||
---------- | ||
|
||
The <file> list given to the command can be exact pathnames, | ||
file glob patterns, or leading directory names. The command | ||
removes only the paths that are known to Git. Giving the name of | ||
a file that you have not told Git about does not remove that file. | ||
--pathspec-file-nul:: | ||
Only meaningful with `--pathspec-from-file`. Pathspec elements are | ||
separated with NUL character and all other characters are taken | ||
literally (including newlines and quotes). | ||
|
||
File globbing matches across directory boundaries. Thus, given | ||
two directories `d` and `d2`, there is a difference between | ||
using `git rm 'd*'` and `git rm 'd/*'`, as the former will | ||
also remove all of directory `d2`. | ||
|
||
REMOVING FILES THAT HAVE DISAPPEARED FROM THE FILESYSTEM | ||
-------------------------------------------------------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ SYNOPSIS | |
'git stash' branch <branchname> [<stash>] | ||
'git stash' [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet] | ||
[-u|--include-untracked] [-a|--all] [-m|--message <message>] | ||
[--pathspec-from-file=<file> [--pathspec-file-nul]] | ||
[--] [<pathspec>...]] | ||
'git stash' clear | ||
'git stash' create [<message>] | ||
|
@@ -43,10 +44,10 @@ created stash, `stash@{1}` is the one before it, `stash@{2.hours.ago}` | |
is also possible). Stashes may also be referenced by specifying just the | ||
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):
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, Alexandr Miloslavskiy wrote (reply to this):
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):
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):
|
||
stash index (e.g. the integer `n` is equivalent to `stash@{n}`). | ||
|
||
OPTIONS | ||
------- | ||
COMMANDS | ||
-------- | ||
|
||
push [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [-m|--message <message>] [--] [<pathspec>...]:: | ||
push [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [-m|--message <message>] [--pathspec-from-file=<file> [--pathspec-file-nul]] [--] [<pathspec>...]:: | ||
|
||
Save your local modifications to a new 'stash entry' and roll them | ||
back to HEAD (in the working tree and in the index). | ||
|
@@ -56,38 +57,13 @@ push [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q | |
For quickly making a snapshot, you can omit "push". In this mode, | ||
non-option arguments are not allowed to prevent a misspelled | ||
subcommand from making an unwanted stash entry. The two exceptions to this | ||
are `stash -p` which acts as alias for `stash push -p` and pathspecs, | ||
are `stash -p` which acts as alias for `stash push -p` and pathspec elements, | ||
which are allowed after a double hyphen `--` for disambiguation. | ||
+ | ||
When pathspec is given to 'git stash push', the new stash entry records the | ||
modified states only for the files that match the pathspec. The index | ||
entries and working tree files are then rolled back to the state in | ||
HEAD only for these files, too, leaving files that do not match the | ||
pathspec intact. | ||
+ | ||
If the `--keep-index` option is used, all changes already added to the | ||
index are left intact. | ||
+ | ||
If the `--include-untracked` option is used, all untracked files are also | ||
stashed and then cleaned up with `git clean`, leaving the working directory | ||
in a very clean state. If the `--all` option is used instead then the | ||
ignored files are stashed and cleaned in addition to the untracked files. | ||
+ | ||
With `--patch`, you can interactively select hunks from the diff | ||
between HEAD and the working tree to be stashed. The stash entry is | ||
constructed such that its index state is the same as the index state | ||
of your repository, and its worktree contains only the changes you | ||
selected interactively. The selected changes are then rolled back | ||
from your worktree. See the ``Interactive Mode'' section of | ||
linkgit:git-add[1] to learn how to operate the `--patch` mode. | ||
+ | ||
The `--patch` option implies `--keep-index`. You can use | ||
`--no-keep-index` to override this. | ||
|
||
save [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [<message>]:: | ||
|
||
This option is deprecated in favour of 'git stash push'. It | ||
differs from "stash push" in that it cannot take pathspecs. | ||
differs from "stash push" in that it cannot take pathspec. | ||
Instead, all non-option arguments are concatenated to form the stash | ||
message. | ||
|
||
|
@@ -111,7 +87,7 @@ show [<options>] [<stash>]:: | |
|
||
Show the changes recorded in the stash entry as a diff between the | ||
stashed contents and the commit back when the stash entry was first | ||
created. When no `<stash>` is given, it shows the latest one. | ||
created. | ||
By default, the command shows the diffstat, but it will accept any | ||
format known to 'git diff' (e.g., `git stash show -p stash@{1}` | ||
to view the second most recent entry in patch form). | ||
|
@@ -128,14 +104,6 @@ pop [--index] [-q|--quiet] [<stash>]:: | |
Applying the state can fail with conflicts; in this case, it is not | ||
removed from the stash list. You need to resolve the conflicts by hand | ||
and call `git stash drop` manually afterwards. | ||
+ | ||
If the `--index` option is used, then tries to reinstate not only the working | ||
tree's changes, but also the index's ones. However, this can fail, when you | ||
have conflicts (which are stored in the index, where you therefore can no | ||
longer apply the changes as they were originally). | ||
+ | ||
When no `<stash>` is given, `stash@{0}` is assumed, otherwise `<stash>` must | ||
be a reference of the form `stash@{<revision>}`. | ||
|
||
apply [--index] [-q|--quiet] [<stash>]:: | ||
|
||
|
@@ -149,8 +117,7 @@ branch <branchname> [<stash>]:: | |
the commit at which the `<stash>` was originally created, applies the | ||
changes recorded in `<stash>` to the new working tree and index. | ||
If that succeeds, and `<stash>` is a reference of the form | ||
`stash@{<revision>}`, it then drops the `<stash>`. When no `<stash>` | ||
is given, applies the latest one. | ||
`stash@{<revision>}`, it then drops the `<stash>`. | ||
+ | ||
This is useful if the branch on which you ran `git stash push` has | ||
changed enough that `git stash apply` fails due to conflicts. Since | ||
|
@@ -166,9 +133,6 @@ clear:: | |
drop [-q|--quiet] [<stash>]:: | ||
|
||
Remove a single stash entry from the list of stash entries. | ||
When no `<stash>` is given, it removes the latest one. | ||
i.e. `stash@{0}`, otherwise `<stash>` must be a valid stash | ||
log reference of the form `stash@{<revision>}`. | ||
|
||
create:: | ||
|
||
|
@@ -185,6 +149,98 @@ store:: | |
reflog. This is intended to be useful for scripts. It is | ||
probably not the command you want to use; see "push" above. | ||
|
||
OPTIONS | ||
------- | ||
-a:: | ||
--all:: | ||
This option is only valid for `push` and `save` commands. | ||
+ | ||
All ignored and untracked files are also stashed and then cleaned | ||
up with `git clean`. | ||
|
||
-u:: | ||
--include-untracked:: | ||
This option is only valid for `push` and `save` commands. | ||
+ | ||
All untracked files are also stashed and then cleaned up with | ||
`git clean`. | ||
|
||
--index:: | ||
This option is only valid for `pop` and `apply` commands. | ||
+ | ||
Tries to reinstate not only the working tree's changes, but also | ||
the index's ones. However, this can fail, when you have conflicts | ||
(which are stored in the index, where you therefore can no longer | ||
apply the changes as they were originally). | ||
|
||
-k:: | ||
--keep-index:: | ||
--no-keep-index:: | ||
This option is only valid for `push` and `save` commands. | ||
+ | ||
All changes already added to the index are left intact. | ||
|
||
-p:: | ||
--patch:: | ||
This option is only valid for `push` and `save` commands. | ||
+ | ||
Interactively select hunks from the diff between HEAD and the | ||
working tree to be stashed. The stash entry is constructed such | ||
that its index state is the same as the index state of your | ||
repository, and its worktree contains only the changes you selected | ||
interactively. The selected changes are then rolled back from your | ||
worktree. See the ``Interactive Mode'' section of linkgit:git-add[1] | ||
to learn how to operate the `--patch` mode. | ||
+ | ||
The `--patch` option implies `--keep-index`. You can use | ||
`--no-keep-index` to override this. | ||
|
||
--pathspec-from-file=<file>:: | ||
This option is only valid for `push` command. | ||
+ | ||
Pathspec is passed in `<file>` instead of commandline args. If | ||
`<file>` is exactly `-` then standard input is used. Pathspec | ||
elements are separated by LF or CR/LF. Pathspec elements can be | ||
quoted as explained for the configuration variable `core.quotePath` | ||
(see linkgit:git-config[1]). See also `--pathspec-file-nul` and | ||
global `--literal-pathspecs`. | ||
|
||
--pathspec-file-nul:: | ||
This option is only valid for `push` command. | ||
+ | ||
Only meaningful with `--pathspec-from-file`. Pathspec elements are | ||
separated with NUL character and all other characters are taken | ||
literally (including newlines and quotes). | ||
|
||
-q:: | ||
--quiet:: | ||
This option is only valid for `apply`, `drop`, `pop`, `push`, | ||
`save`, `store` commands. | ||
+ | ||
Quiet, suppress feedback messages. | ||
|
||
\--:: | ||
This option is only valid for `push` command. | ||
+ | ||
Separates pathspec from options for disambiguation purposes. | ||
|
||
<pathspec>...:: | ||
This option is only valid for `push` command. | ||
+ | ||
The new stash entry records the modified states only for the files | ||
that match the pathspec. The index entries and working tree files | ||
are then rolled back to the state in HEAD only for these files, | ||
too, leaving files that do not match the pathspec intact. | ||
+ | ||
For more details, see the 'pathspec' entry in linkgit:gitglossary[7]. | ||
|
||
<stash>:: | ||
This option is only valid for `apply`, `branch`, `drop`, `pop`, | ||
`show` commands. | ||
+ | ||
A reference of the form `stash@{<revision>}`. When no `<stash>` is | ||
given, the latest stash is assumed (that is, `stash@{0}`). | ||
|
||
DISCUSSION | ||
---------- | ||
|
||
|
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, Junio C Hamano wrote (reply to this):