git 如何重命名 GitHub 网站上的目录/文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31861651/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:26:14  来源:igfitidea点击:

How to rename a directory/folder on GitHub website?

gitfilegithubdirectoryrename

提问by committedandroider

I was able to find a way on GitHub Website to renamea single file and did so with success.

我能够在 GitHub 网站上找到一种方法来重命名单个文件,并且成功地做到了。

I was also able to find a way to renamea whole repository and did that with success.

我还能够找到一种方法来重命名整个存储库并成功地做到了这一点。

Does anyone know how to do this to a single directory without using command line? For reference, I am trying to change a directory named InterviewTesting (that contains src files, etc) to something else. I tried doing it the single file way. enter image description here
But this didn't allow me to change the name of the directory (InterviewTesting), only the actual file name.

有谁知道如何在不使用命令行的情况下对单个目录执行此操作?作为参考,我正在尝试将名为 InterviewTesting(包含 src 文件等)的目录更改为其他内容。我试着用单文件的方式来做。但这不允许我更改目录的名称(InterviewTesting),只能更改实际的文件名。在此处输入图片说明

回答by Jonatas Walker

Actually, there is a way to rename a folder using web interface.

实际上,有一种使用 Web 界面重命名文件夹的方法。

1) Type a folder name followed by slash to go down into a subfolder. 2) Type dot dot, then slash, to jump upwards one directory. 3) Use the backspace key to edit the parent directory's name.

1) 键入文件夹名称后跟斜杠以进入子文件夹。 2) 输入dot dot,然后输入slash,向上跳转一个目录。 3) 使用退格键编辑父目录的名称。

See https://github.com/blog/1436-moving-and-renaming-files-on-github

https://github.com/blog/1436-moving-and-renaming-files-on-github

回答by Kevin Marin

There is no way to do this in the GitHub web application. I believe to only way to do this is in the command line using git mv <old name> <new name>or by using a Git client(like SourceTree).

在 GitHub Web 应用程序中无法执行此操作。我相信唯一的方法是在命令行中使用git mv <old name> <new name>或使用 Git 客户端(如SourceTree)。

回答by Dean_CamDo

You can! Just press edit as per @committedandroider's original post and then hit backspace with your cursor at the start of the filename. It will let you then edit the folder. When done hit forward slash to then edit the filename again.

你可以!只需按照@committedandroider 的原始帖子按编辑,然后在文件名的开头用光标点击退格键。然后它会让你编辑文件夹。完成后点击正斜杠,然后再次编辑文件名。

回答by Benaboki

I had an issue with github missing out on some case sensitive changes to folders. I needed to keep migration history so an example of how I changed "basicApp" folder in github to "basicapp"

我有一个问题,github 错过了对文件夹的一些区分大小写的更改。我需要保留迁移历史记录,因此我将举例说明如何将 github 中的“basicApp”文件夹更改为“basicapp”

$ git ls-files
$ git mv basicApp basicapp_temp
$ git add .
$ git commit -am "temporary change"
$ git push origin master
$ git mv basicapp_temp basicapp
$ git add .
$ git commit -am "change to desired name"
$ git push origin master

PS: git ls-fileswill show you how github sees your folder name

PS:git ls-files会告诉你github如何看到你的文件夹名称

回答by Nica

If you have GitHub Desktop, change the names of the directories on your computer and then push the update from your desktop to your github account and it changes them there. :)

如果您有 GitHub Desktop,请更改您计算机上目录的名称,然后将更新从您的桌面推送到您的 github 帐户,并在那里更改它们。:)

Hope it helps!

希望能帮助到你!

回答by jouell

As a newer user to git, I took the following approach. From the command line, I was able to rename a folder by creating a new folder, copying the files to it, adding and commiting locally and pushing. These are my steps:

作为 git 的新用户,我采用了以下方法。从命令行,我能够通过创建一个新文件夹、将文件复制到其中、在本地添加和提交以及推送来重命名文件夹。这些是我的步骤:

$mkdir newfolder 
$cp oldfolder/* newfolder
$git add newfolder 
$git commit -m 'start rename'     
$git push                             #New Folder appears on Github      
$git rm -r oldfolder
$git commit -m 'rename complete' 
$git push                             #Old Folder disappears on Github  

Probably a better way, but it worked for me.

可能是更好的方法,但它对我有用。

回答by Xornack

Go into your directory and click on 'Settings' next to the little cog. There is a field to rename your directory.

进入您的目录,然后单击小齿轮旁边的“设置”。有一个字段可以重命名您的目录。

回答by Wenxiao Lu

I changed the 'Untitlted Folder' name by going upward one directory where the untitled folder and other docs are listed.

我通过向上移动一个目录来更改“无标题文件夹”名称,其中列出了无标题文件夹和其他文档。

Tick the little white box in front of the 'Untitled Folder', a 'rename' button will show up at the top. Then click and change the folder name into whatever kinky name you want.

勾选“无标题文件夹”前面的小白框,顶部会显示“重命名”按钮。然后单击并将文件夹名称更改为您想要的任何古怪名称。

See the 'Rename' button?

看到“重命名”按钮了吗?

See the 'Rename' button?

看到“重命名”按钮了吗?