我认为它应该工作,复制目录要重命名到一个新的目录与所需的名称,并删除旧目录,git添加,git提交和推一切。但这是最好的方法吗?
当前回答
基本重命名(或移动):
git mv <old name> <new name>
区分大小写的重命名。从大小写敏感到大小写敏感-你必须使用两个步骤:
git mv casesensitive tmp
git mv tmp CaseSensitive
(更多关于Git中的大小写敏感性…)
…然后是commit和push,这是在git repo中重命名目录的最简单方法。
其他回答
在git中重命名是困难的,因为索引必须改变,并且树对象将在提交后创建。 我有重命名模板为模板的问题… 我用……解决了这个问题
copying Templates to templates in bash [cp -r Templates templates ] (git mv Templates templates will not work) removing Templates in bash [rm -r Templates ](check that the copying was successful first) Removing the Templates file from the index[use "git ls-files -s" to see the index, "git rm " you can use wildcards such as git rm Templates/*, continue checking the index] Adding the renamed paths to the index ("git add -v ." and check the result with "git ls-files -s" Commit ["git commit -m "renaming ... " If you have remotes git push <to wherever origin,
如果你收到这个错误:fatal:重命名' foldername ' failed:无效参数
试试这个:
* nixOS
git mv文件夹
酒鬼
git config核心。ignorecase虚假;git mv文件夹;git mv寺庙
简单的技巧
您可以用任何临时名称重命名目录,然后再次重命名,这样就可以工作了
可以使用文件系统重命名目录。然后你可以做git rm <旧目录>和git add <新目录>(帮助页面)。然后你就可以承诺并推动。
Git会检测到内容是相同的,这只是一个重命名操作,它将作为重命名条目出现在历史记录中。您可以在提交之前使用git状态检查情况是否如此
很多正确答案,但当我登陆这里复制和粘贴一个文件夹重命名历史,我发现 这
git mv <old name> <new name>
是否将旧文件夹(本身)移动到新文件夹中
而
git mv <old name>/ <new name>
(注意'/') 将嵌套内容从旧文件夹移动到新文件夹
这两个命令都没有沿着嵌套文件的历史记录进行复制。我最终重新命名了每个嵌套的文件夹
git mv <old name>/<nest-folder> <new name>/<nest-folder>
推荐文章
- GitHub -致命:无法读取用户名https://github.com':没有这样的文件或目录
- 撤消git平分错误
- 使用.gitconfig配置diff工具
- 如何配置Mac OS X术语,使git有颜色?
- Visual Studio Code: .git文件夹/文件隐藏
- “node_modules”文件夹应该包含在git存储库中吗
- 为什么git-rebase给了我合并冲突,而我所做的只是压缩提交?
- 当我试图推到原点时,为什么Git告诉我“没有这样的远程‘原点’”?
- 如何从远程分支中挑选?
- 如何查看一个分支中的哪些提交不在另一个分支中?
- 如何取消在github上的拉请求?
- HEAD和master的区别
- GIT克隆在windows中跨本地文件系统回购
- RPC失败;卷度传输已关闭,剩余未完成的读取数据
- 我应该在.gitignore文件中添加Django迁移文件吗?