git rename a file starting with a dash [duplicate]
up vote
0
down vote
favorite
This question already has an answer here:
Escaping in git add a leading “-” in the filename?
2 answers
I have been and made a file called "-_todo.txt" in my git folder which I have been happily using since to keep a list of my todos. Now I'd like to rename it something more sensible e.g. "todo.txt". I understood you should use "git mv" to do so. However
git mv -_todo.txt todo.txt
gives me an error: unknown switch. Trying out for the sake of trying
git mv "-_todo.txt" todo.txt
gave the same error.
Searching the internet the last 30 minutes with my favorite search engine didnt help me find anything useful ("git mv filename with underscore"). The official docs on "git mv" didnt help either.
How to rename such a file?
Note on duplication:
Although I agree - in hindsight - this question has been answered elsewhere, the associated title of that question is arguably a bit cryptic/hard to find if searching for something like "git mv filename with underscore [in it]". Maybe improve the title/search-ability of that question/answer? - maybe Im being a hassle.
git
marked as duplicate by HostileFork, melpomene, torek
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 10 at 11:04
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
0
down vote
favorite
This question already has an answer here:
Escaping in git add a leading “-” in the filename?
2 answers
I have been and made a file called "-_todo.txt" in my git folder which I have been happily using since to keep a list of my todos. Now I'd like to rename it something more sensible e.g. "todo.txt". I understood you should use "git mv" to do so. However
git mv -_todo.txt todo.txt
gives me an error: unknown switch. Trying out for the sake of trying
git mv "-_todo.txt" todo.txt
gave the same error.
Searching the internet the last 30 minutes with my favorite search engine didnt help me find anything useful ("git mv filename with underscore"). The official docs on "git mv" didnt help either.
How to rename such a file?
Note on duplication:
Although I agree - in hindsight - this question has been answered elsewhere, the associated title of that question is arguably a bit cryptic/hard to find if searching for something like "git mv filename with underscore [in it]". Maybe improve the title/search-ability of that question/answer? - maybe Im being a hassle.
git
marked as duplicate by HostileFork, melpomene, torek
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 10 at 11:04
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
test it with./-_todo.txt
– Mohammad Ali Taqvazadeh
Nov 10 at 10:53
It definitely boils down to the same problem. Thanks @HostileFork
– balletpiraat
Nov 10 at 11:06
1
"Maybe improve the title/search-ability of that question/answer? - maybe Im being a hassle." -> This is actually why duplicates are not considered a bad thing. Duplicates offer more wording entry points for the search engine to find. FWIW, I found it by searching on how to "escape" dashes because that is the more precise general terminology...and so the other question's title makes sense to me (and probably others).
– HostileFork
Nov 10 at 11:24
I see, because the normal meaning of the dash (specifying optional arguments) has to be "escaped from" you call the '--' an escape character, right? Thanks for the additional information.
– balletpiraat
Nov 10 at 11:31
@balletpiraat "Escaping" is like what you do with backslashes, such as when you want to do"a "quoted string" like this"
to geta "quoted string" like this
. So I wondered if there was something like that for the dash. It appears not, so you've found other options. But I still would think of it as "looking for an escaping mechanism"...that's where I'd start my search if I had this problem.
– HostileFork
Nov 10 at 11:39
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
Escaping in git add a leading “-” in the filename?
2 answers
I have been and made a file called "-_todo.txt" in my git folder which I have been happily using since to keep a list of my todos. Now I'd like to rename it something more sensible e.g. "todo.txt". I understood you should use "git mv" to do so. However
git mv -_todo.txt todo.txt
gives me an error: unknown switch. Trying out for the sake of trying
git mv "-_todo.txt" todo.txt
gave the same error.
Searching the internet the last 30 minutes with my favorite search engine didnt help me find anything useful ("git mv filename with underscore"). The official docs on "git mv" didnt help either.
How to rename such a file?
Note on duplication:
Although I agree - in hindsight - this question has been answered elsewhere, the associated title of that question is arguably a bit cryptic/hard to find if searching for something like "git mv filename with underscore [in it]". Maybe improve the title/search-ability of that question/answer? - maybe Im being a hassle.
git
This question already has an answer here:
Escaping in git add a leading “-” in the filename?
2 answers
I have been and made a file called "-_todo.txt" in my git folder which I have been happily using since to keep a list of my todos. Now I'd like to rename it something more sensible e.g. "todo.txt". I understood you should use "git mv" to do so. However
git mv -_todo.txt todo.txt
gives me an error: unknown switch. Trying out for the sake of trying
git mv "-_todo.txt" todo.txt
gave the same error.
Searching the internet the last 30 minutes with my favorite search engine didnt help me find anything useful ("git mv filename with underscore"). The official docs on "git mv" didnt help either.
How to rename such a file?
Note on duplication:
Although I agree - in hindsight - this question has been answered elsewhere, the associated title of that question is arguably a bit cryptic/hard to find if searching for something like "git mv filename with underscore [in it]". Maybe improve the title/search-ability of that question/answer? - maybe Im being a hassle.
This question already has an answer here:
Escaping in git add a leading “-” in the filename?
2 answers
git
git
edited Nov 10 at 11:12
asked Nov 10 at 10:50
balletpiraat
1218
1218
marked as duplicate by HostileFork, melpomene, torek
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 10 at 11:04
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by HostileFork, melpomene, torek
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 10 at 11:04
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
test it with./-_todo.txt
– Mohammad Ali Taqvazadeh
Nov 10 at 10:53
It definitely boils down to the same problem. Thanks @HostileFork
– balletpiraat
Nov 10 at 11:06
1
"Maybe improve the title/search-ability of that question/answer? - maybe Im being a hassle." -> This is actually why duplicates are not considered a bad thing. Duplicates offer more wording entry points for the search engine to find. FWIW, I found it by searching on how to "escape" dashes because that is the more precise general terminology...and so the other question's title makes sense to me (and probably others).
– HostileFork
Nov 10 at 11:24
I see, because the normal meaning of the dash (specifying optional arguments) has to be "escaped from" you call the '--' an escape character, right? Thanks for the additional information.
– balletpiraat
Nov 10 at 11:31
@balletpiraat "Escaping" is like what you do with backslashes, such as when you want to do"a "quoted string" like this"
to geta "quoted string" like this
. So I wondered if there was something like that for the dash. It appears not, so you've found other options. But I still would think of it as "looking for an escaping mechanism"...that's where I'd start my search if I had this problem.
– HostileFork
Nov 10 at 11:39
add a comment |
1
test it with./-_todo.txt
– Mohammad Ali Taqvazadeh
Nov 10 at 10:53
It definitely boils down to the same problem. Thanks @HostileFork
– balletpiraat
Nov 10 at 11:06
1
"Maybe improve the title/search-ability of that question/answer? - maybe Im being a hassle." -> This is actually why duplicates are not considered a bad thing. Duplicates offer more wording entry points for the search engine to find. FWIW, I found it by searching on how to "escape" dashes because that is the more precise general terminology...and so the other question's title makes sense to me (and probably others).
– HostileFork
Nov 10 at 11:24
I see, because the normal meaning of the dash (specifying optional arguments) has to be "escaped from" you call the '--' an escape character, right? Thanks for the additional information.
– balletpiraat
Nov 10 at 11:31
@balletpiraat "Escaping" is like what you do with backslashes, such as when you want to do"a "quoted string" like this"
to geta "quoted string" like this
. So I wondered if there was something like that for the dash. It appears not, so you've found other options. But I still would think of it as "looking for an escaping mechanism"...that's where I'd start my search if I had this problem.
– HostileFork
Nov 10 at 11:39
1
1
test it with
./-_todo.txt
– Mohammad Ali Taqvazadeh
Nov 10 at 10:53
test it with
./-_todo.txt
– Mohammad Ali Taqvazadeh
Nov 10 at 10:53
It definitely boils down to the same problem. Thanks @HostileFork
– balletpiraat
Nov 10 at 11:06
It definitely boils down to the same problem. Thanks @HostileFork
– balletpiraat
Nov 10 at 11:06
1
1
"Maybe improve the title/search-ability of that question/answer? - maybe Im being a hassle." -> This is actually why duplicates are not considered a bad thing. Duplicates offer more wording entry points for the search engine to find. FWIW, I found it by searching on how to "escape" dashes because that is the more precise general terminology...and so the other question's title makes sense to me (and probably others).
– HostileFork
Nov 10 at 11:24
"Maybe improve the title/search-ability of that question/answer? - maybe Im being a hassle." -> This is actually why duplicates are not considered a bad thing. Duplicates offer more wording entry points for the search engine to find. FWIW, I found it by searching on how to "escape" dashes because that is the more precise general terminology...and so the other question's title makes sense to me (and probably others).
– HostileFork
Nov 10 at 11:24
I see, because the normal meaning of the dash (specifying optional arguments) has to be "escaped from" you call the '--' an escape character, right? Thanks for the additional information.
– balletpiraat
Nov 10 at 11:31
I see, because the normal meaning of the dash (specifying optional arguments) has to be "escaped from" you call the '--' an escape character, right? Thanks for the additional information.
– balletpiraat
Nov 10 at 11:31
@balletpiraat "Escaping" is like what you do with backslashes, such as when you want to do
"a "quoted string" like this"
to get a "quoted string" like this
. So I wondered if there was something like that for the dash. It appears not, so you've found other options. But I still would think of it as "looking for an escaping mechanism"...that's where I'd start my search if I had this problem.– HostileFork
Nov 10 at 11:39
@balletpiraat "Escaping" is like what you do with backslashes, such as when you want to do
"a "quoted string" like this"
to get a "quoted string" like this
. So I wondered if there was something like that for the dash. It appears not, so you've found other options. But I still would think of it as "looking for an escaping mechanism"...that's where I'd start my search if I had this problem.– HostileFork
Nov 10 at 11:39
add a comment |
2 Answers
2
active
oldest
votes
up vote
3
down vote
accepted
You can use --
to separate between git's switches and the file names, so you won't even have to escape the -
in the file name:
$ git mv -- -_todo.txt todo.txt
awesome, thank you! Could be helpful if this would be explained in the git mv docs - maybe too much to ask, would make the docs cluttered?
– balletpiraat
Nov 10 at 11:03
@balletpiraat Please set correct answer as Accepted Answer, so others can use your question. Good Luck
– Mohammad Ali Taqvazadeh
Nov 10 at 11:05
@MohammadAliTaqvazadeh Will do, thanks.
– balletpiraat
Nov 10 at 11:07
add a comment |
up vote
2
down vote
Since git tries to parse the -
as a flag you have to use ./
# use the full path to avoid parse the prefix as parameter
git mv "./-_todo.txt" todo.txt
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
You can use --
to separate between git's switches and the file names, so you won't even have to escape the -
in the file name:
$ git mv -- -_todo.txt todo.txt
awesome, thank you! Could be helpful if this would be explained in the git mv docs - maybe too much to ask, would make the docs cluttered?
– balletpiraat
Nov 10 at 11:03
@balletpiraat Please set correct answer as Accepted Answer, so others can use your question. Good Luck
– Mohammad Ali Taqvazadeh
Nov 10 at 11:05
@MohammadAliTaqvazadeh Will do, thanks.
– balletpiraat
Nov 10 at 11:07
add a comment |
up vote
3
down vote
accepted
You can use --
to separate between git's switches and the file names, so you won't even have to escape the -
in the file name:
$ git mv -- -_todo.txt todo.txt
awesome, thank you! Could be helpful if this would be explained in the git mv docs - maybe too much to ask, would make the docs cluttered?
– balletpiraat
Nov 10 at 11:03
@balletpiraat Please set correct answer as Accepted Answer, so others can use your question. Good Luck
– Mohammad Ali Taqvazadeh
Nov 10 at 11:05
@MohammadAliTaqvazadeh Will do, thanks.
– balletpiraat
Nov 10 at 11:07
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
You can use --
to separate between git's switches and the file names, so you won't even have to escape the -
in the file name:
$ git mv -- -_todo.txt todo.txt
You can use --
to separate between git's switches and the file names, so you won't even have to escape the -
in the file name:
$ git mv -- -_todo.txt todo.txt
answered Nov 10 at 10:56
Mureinik
176k22127196
176k22127196
awesome, thank you! Could be helpful if this would be explained in the git mv docs - maybe too much to ask, would make the docs cluttered?
– balletpiraat
Nov 10 at 11:03
@balletpiraat Please set correct answer as Accepted Answer, so others can use your question. Good Luck
– Mohammad Ali Taqvazadeh
Nov 10 at 11:05
@MohammadAliTaqvazadeh Will do, thanks.
– balletpiraat
Nov 10 at 11:07
add a comment |
awesome, thank you! Could be helpful if this would be explained in the git mv docs - maybe too much to ask, would make the docs cluttered?
– balletpiraat
Nov 10 at 11:03
@balletpiraat Please set correct answer as Accepted Answer, so others can use your question. Good Luck
– Mohammad Ali Taqvazadeh
Nov 10 at 11:05
@MohammadAliTaqvazadeh Will do, thanks.
– balletpiraat
Nov 10 at 11:07
awesome, thank you! Could be helpful if this would be explained in the git mv docs - maybe too much to ask, would make the docs cluttered?
– balletpiraat
Nov 10 at 11:03
awesome, thank you! Could be helpful if this would be explained in the git mv docs - maybe too much to ask, would make the docs cluttered?
– balletpiraat
Nov 10 at 11:03
@balletpiraat Please set correct answer as Accepted Answer, so others can use your question. Good Luck
– Mohammad Ali Taqvazadeh
Nov 10 at 11:05
@balletpiraat Please set correct answer as Accepted Answer, so others can use your question. Good Luck
– Mohammad Ali Taqvazadeh
Nov 10 at 11:05
@MohammadAliTaqvazadeh Will do, thanks.
– balletpiraat
Nov 10 at 11:07
@MohammadAliTaqvazadeh Will do, thanks.
– balletpiraat
Nov 10 at 11:07
add a comment |
up vote
2
down vote
Since git tries to parse the -
as a flag you have to use ./
# use the full path to avoid parse the prefix as parameter
git mv "./-_todo.txt" todo.txt
add a comment |
up vote
2
down vote
Since git tries to parse the -
as a flag you have to use ./
# use the full path to avoid parse the prefix as parameter
git mv "./-_todo.txt" todo.txt
add a comment |
up vote
2
down vote
up vote
2
down vote
Since git tries to parse the -
as a flag you have to use ./
# use the full path to avoid parse the prefix as parameter
git mv "./-_todo.txt" todo.txt
Since git tries to parse the -
as a flag you have to use ./
# use the full path to avoid parse the prefix as parameter
git mv "./-_todo.txt" todo.txt
answered Nov 10 at 10:56
CodeWizard
49.4k126788
49.4k126788
add a comment |
add a comment |
1
test it with
./-_todo.txt
– Mohammad Ali Taqvazadeh
Nov 10 at 10:53
It definitely boils down to the same problem. Thanks @HostileFork
– balletpiraat
Nov 10 at 11:06
1
"Maybe improve the title/search-ability of that question/answer? - maybe Im being a hassle." -> This is actually why duplicates are not considered a bad thing. Duplicates offer more wording entry points for the search engine to find. FWIW, I found it by searching on how to "escape" dashes because that is the more precise general terminology...and so the other question's title makes sense to me (and probably others).
– HostileFork
Nov 10 at 11:24
I see, because the normal meaning of the dash (specifying optional arguments) has to be "escaped from" you call the '--' an escape character, right? Thanks for the additional information.
– balletpiraat
Nov 10 at 11:31
@balletpiraat "Escaping" is like what you do with backslashes, such as when you want to do
"a "quoted string" like this"
to geta "quoted string" like this
. So I wondered if there was something like that for the dash. It appears not, so you've found other options. But I still would think of it as "looking for an escaping mechanism"...that's where I'd start my search if I had this problem.– HostileFork
Nov 10 at 11:39