Escaping in git add a leading “-” in the filename?
up vote
2
down vote
favorite
In git add how can you escape a leading "-" character in the filename? e.g.:
git add -index-apache-.html
gives:
error: unknown switch `d'
Thanks!
PS. same for
git checkout
git
add a comment |
up vote
2
down vote
favorite
In git add how can you escape a leading "-" character in the filename? e.g.:
git add -index-apache-.html
gives:
error: unknown switch `d'
Thanks!
PS. same for
git checkout
git
3
Trygit add -- -index-apache-.html
. For more details, see this answer.
– jubobs
Sep 6 '14 at 18:39
1
@Jubobs, thanks, it works!
– pebox11
Sep 6 '14 at 18:46
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
In git add how can you escape a leading "-" character in the filename? e.g.:
git add -index-apache-.html
gives:
error: unknown switch `d'
Thanks!
PS. same for
git checkout
git
In git add how can you escape a leading "-" character in the filename? e.g.:
git add -index-apache-.html
gives:
error: unknown switch `d'
Thanks!
PS. same for
git checkout
git
git
asked Sep 6 '14 at 18:36
pebox11
502623
502623
3
Trygit add -- -index-apache-.html
. For more details, see this answer.
– jubobs
Sep 6 '14 at 18:39
1
@Jubobs, thanks, it works!
– pebox11
Sep 6 '14 at 18:46
add a comment |
3
Trygit add -- -index-apache-.html
. For more details, see this answer.
– jubobs
Sep 6 '14 at 18:39
1
@Jubobs, thanks, it works!
– pebox11
Sep 6 '14 at 18:46
3
3
Try
git add -- -index-apache-.html
. For more details, see this answer.– jubobs
Sep 6 '14 at 18:39
Try
git add -- -index-apache-.html
. For more details, see this answer.– jubobs
Sep 6 '14 at 18:39
1
1
@Jubobs, thanks, it works!
– pebox11
Sep 6 '14 at 18:46
@Jubobs, thanks, it works!
– pebox11
Sep 6 '14 at 18:46
add a comment |
2 Answers
2
active
oldest
votes
up vote
5
down vote
accepted
Use the --
to get around this issue. Anything past the double-dash is treated as just a filename.
This is more a Bash convention than a Git convention, as --
traditionally signifies the end of options.
A
--
signals the end of options and disables further option processing. Any arguments after the--
are treated as filenames and arguments. An argument of-
is equivalent to--
.
add a comment |
up vote
1
down vote
As an alternative to the general --
syntax,
git add -- -index-apache-.html
you could also use
git add ./-index-apache-.html
This works because the argument is a filename. Prepending ./
says "look for this file in the current directory", so it does not change the meaning of the filename (git would've looked there anyway), but it also means the argument no longer starts with -
and cannot be confused with option switches.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
Use the --
to get around this issue. Anything past the double-dash is treated as just a filename.
This is more a Bash convention than a Git convention, as --
traditionally signifies the end of options.
A
--
signals the end of options and disables further option processing. Any arguments after the--
are treated as filenames and arguments. An argument of-
is equivalent to--
.
add a comment |
up vote
5
down vote
accepted
Use the --
to get around this issue. Anything past the double-dash is treated as just a filename.
This is more a Bash convention than a Git convention, as --
traditionally signifies the end of options.
A
--
signals the end of options and disables further option processing. Any arguments after the--
are treated as filenames and arguments. An argument of-
is equivalent to--
.
add a comment |
up vote
5
down vote
accepted
up vote
5
down vote
accepted
Use the --
to get around this issue. Anything past the double-dash is treated as just a filename.
This is more a Bash convention than a Git convention, as --
traditionally signifies the end of options.
A
--
signals the end of options and disables further option processing. Any arguments after the--
are treated as filenames and arguments. An argument of-
is equivalent to--
.
Use the --
to get around this issue. Anything past the double-dash is treated as just a filename.
This is more a Bash convention than a Git convention, as --
traditionally signifies the end of options.
A
--
signals the end of options and disables further option processing. Any arguments after the--
are treated as filenames and arguments. An argument of-
is equivalent to--
.
edited Sep 6 '14 at 18:46
answered Sep 6 '14 at 18:41
Makoto
78.9k15122164
78.9k15122164
add a comment |
add a comment |
up vote
1
down vote
As an alternative to the general --
syntax,
git add -- -index-apache-.html
you could also use
git add ./-index-apache-.html
This works because the argument is a filename. Prepending ./
says "look for this file in the current directory", so it does not change the meaning of the filename (git would've looked there anyway), but it also means the argument no longer starts with -
and cannot be confused with option switches.
add a comment |
up vote
1
down vote
As an alternative to the general --
syntax,
git add -- -index-apache-.html
you could also use
git add ./-index-apache-.html
This works because the argument is a filename. Prepending ./
says "look for this file in the current directory", so it does not change the meaning of the filename (git would've looked there anyway), but it also means the argument no longer starts with -
and cannot be confused with option switches.
add a comment |
up vote
1
down vote
up vote
1
down vote
As an alternative to the general --
syntax,
git add -- -index-apache-.html
you could also use
git add ./-index-apache-.html
This works because the argument is a filename. Prepending ./
says "look for this file in the current directory", so it does not change the meaning of the filename (git would've looked there anyway), but it also means the argument no longer starts with -
and cannot be confused with option switches.
As an alternative to the general --
syntax,
git add -- -index-apache-.html
you could also use
git add ./-index-apache-.html
This works because the argument is a filename. Prepending ./
says "look for this file in the current directory", so it does not change the meaning of the filename (git would've looked there anyway), but it also means the argument no longer starts with -
and cannot be confused with option switches.
edited yesterday
answered yesterday
melpomene
55.5k54387
55.5k54387
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f25703528%2fescaping-in-git-add-a-leading-in-the-filename%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
3
Try
git add -- -index-apache-.html
. For more details, see this answer.– jubobs
Sep 6 '14 at 18:39
1
@Jubobs, thanks, it works!
– pebox11
Sep 6 '14 at 18:46