我认为它应该工作,复制目录要重命名到一个新的目录与所需的名称,并删除旧目录,git添加,git提交和推一切。但这是最好的方法吗?


当前回答

1. 将一个文件夹的名称从oldfolder改为newfolder

git mv oldfolder newfolder

2. 如果newfolder已经在你的存储库中&你想覆盖它并使用:- force

git mv -f oldfolder newfolder

不要忘记将更改添加到索引中,并在使用git mv重命名后提交。

3.在不区分大小写的文件系统上将foldername重命名为foldername

简单地用普通mv命令重命名(不是git mv)将不会被识别为来自git的文件更改。如果您尝试使用' git mv '命令,如下面一行

git mv foldername folderName

如果你正在使用一个不区分大小写的文件系统,例如你在Mac上,你没有配置它是区分大小写的,你会遇到这样一个错误消息:

fatal:重命名' foldername '失败:无效参数

以下是你可以做的事情,以使它工作:-

git mv foldername tempname && git mv tempname folderName

This splits up the renaming process by renaming the folder at first to a completely different foldername. After renaming it to the different foldername the folder can finally be renamed to the new folderName. After those ‘git mv’s, again, do not forget to add and commit the changes. Though this is probably not a beautiful technique, it works perfectly fine. The filesystem will still not recognize a change of the letter cases, but git does due to renaming it to a new foldername, and that’s all we wanted :)

其他回答

如果你收到这个错误:fatal:重命名' foldername ' failed:无效参数

试试这个:

* nixOS

git mv文件夹

酒鬼

git config核心。ignorecase虚假;git mv文件夹;git mv寺庙

基本重命名(或移动):

git mv <old name> <new name>

区分大小写的重命名。从大小写敏感到大小写敏感-你必须使用两个步骤:

git mv casesensitive tmp
git mv tmp CaseSensitive

(更多关于Git中的大小写敏感性…)

…然后是commit和push,这是在git repo中重命名目录的最简单方法。

从Web应用程序我认为你不能,但是你可以重命名Git客户端的所有文件夹,它会把你的文件移动到新重命名的文件夹中,然后提交和推送到远程存储库。

我也遇到过类似的问题: 我不得不重命名不同的文件夹从大写到小写(像Abc -> Abc),我已经重命名了所有的文件夹与一个假的名字(像'abc___'),然后提交到远程存储库,之后我重命名所有的文件夹与小写的原始名称(像Abc),它采取了他们!

1. 将一个文件夹的名称从oldfolder改为newfolder

git mv oldfolder newfolder

2. 如果newfolder已经在你的存储库中&你想覆盖它并使用:- force

git mv -f oldfolder newfolder

不要忘记将更改添加到索引中,并在使用git mv重命名后提交。

3.在不区分大小写的文件系统上将foldername重命名为foldername

简单地用普通mv命令重命名(不是git mv)将不会被识别为来自git的文件更改。如果您尝试使用' git mv '命令,如下面一行

git mv foldername folderName

如果你正在使用一个不区分大小写的文件系统,例如你在Mac上,你没有配置它是区分大小写的,你会遇到这样一个错误消息:

fatal:重命名' foldername '失败:无效参数

以下是你可以做的事情,以使它工作:-

git mv foldername tempname && git mv tempname folderName

This splits up the renaming process by renaming the folder at first to a completely different foldername. After renaming it to the different foldername the folder can finally be renamed to the new folderName. After those ‘git mv’s, again, do not forget to add and commit the changes. Though this is probably not a beautiful technique, it works perfectly fine. The filesystem will still not recognize a change of the letter cases, but git does due to renaming it to a new foldername, and that’s all we wanted :)

下面是重命名目录的示例。

git mv src/dir1/ src/dir2/

如果您得到一个声明权限被拒绝的错误,您可以尝试

git mv src/dir1 src/temp/
git mv src/temp src/dir2