我认为它应该工作,复制目录要重命名到一个新的目录与所需的名称,并删除旧目录,git添加,git提交和推一切。但这是最好的方法吗?
当前回答
只需重命名文件夹。git是一个“内容跟踪器”,所以SHA1哈希值是相同的,git知道,你重命名它。唯一改变的是树对象。
$ rm <directory> // remove the directory
$ git add . // add changes to the git
$ git commit // commit removed directory
其他回答
只需重命名文件夹。git是一个“内容跟踪器”,所以SHA1哈希值是相同的,git知道,你重命名它。唯一改变的是树对象。
$ rm <directory> // remove the directory
$ git add . // add changes to the git
$ git commit // commit removed directory
如果你收到这个错误:fatal:重命名' foldername ' failed:无效参数
试试这个:
* nixOS
git mv文件夹
酒鬼
git config核心。ignorecase虚假;git mv文件夹;git mv寺庙
对于区分大小写的重命名,git mv somefolder somefolder以前为我工作过,但今天由于某种原因没有。所以作为一个解决方案,我创建了一个新文件夹temp,将somefolder的所有内容移动到temp,删除somefolder,提交temp,然后创建somefolder,将temp的所有内容移动到somefolder,删除temp,提交并推送somefolder,它工作了!在git中显示为someFolder。
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 :)
我尝试了下面的命令,它没有工作。我收到了一个致命的消息:重命名……' failed:无效参数错误。
git mv oldName NewName
然后用以下方法求解:
首先,我复制了我想重命名的文件夹 然后我运行以下命令删除文件夹
git rm oldName -r
重命名复制文件夹为NewName
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- 如何复制在bash所有目录和文件递归?
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 在Bash命令提示符上添加git分支
- 如何更改Git日志日期格式