[英]How do I rename a local-only repository on 'GitHub desktop' - without renaming repository directory
I have a local repository (has a local remote-origin file://<remote>
).我有一个本地存储库(有一个本地远程源
file://<remote>
)。
How do I change the displayed name of this repository in the Github desktop
app without having to rename the repository directory name.如何在
Github desktop
应用程序中更改此存储库的显示名称,而无需重命名存储库目录名称。
Problem is: C:\\Project1\\Website
& C:\\Project2\\Website
- both show up as Website问题是:
C:\\Project1\\Website
& C:\\Project2\\Website
- 都显示为网站
I want to refrain from having to have: C:\\Project1\\Project1-Website
我想避免必须拥有:
C:\\Project1\\Project1-Website
I set the .git\\description
file - did not work.我设置了
.git\\description
文件 - 没有用。
I set the remote origin URL
to <path>\\Project-Website.git
- did not work.我将
remote origin URL
设置为<path>\\Project-Website.git
- 没有用。
I tried git clone <path>\\Project-Website.git Project-Website
- did not work.我试过
git clone <path>\\Project-Website.git Project-Website
- 没有用。
This is the mess that it causes:这是它造成的混乱:
UPDATE: This has been resolved now - with the "Add Alias" feature.更新:现在已经解决了 - 使用“添加别名”功能。
It turns out git
itself has no provision to specify the repository name.事实证明
git
本身没有规定指定存储库名称。 The root directory name is the single source of truth pertaining to repository name.根目录名称是与存储库名称有关的唯一真实来源。 The
.git/description
though is used only by some applications like Gitweb
.虽然
.git/description
仅被某些应用程序使用,例如Gitweb
。
Also GitHub desktop
has no provision to rename the local repositories.此外,
GitHub desktop
也没有重命名本地存储库的规定。
To override displayed repo names ( to be run in dev-tools: [ View
> Toggle developer tools
] ) Best to save it as a snippet ( Sources
> Snippets
) [unfortunately this will have to be run on each start]要覆盖显示的存储库名称(在开发工具中运行:[
View
> Toggle developer tools
])最好将其保存为片段( Sources
> Snippets
)[不幸的是,这必须在每次启动时运行]
function getElementByXpath(path) {
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}
function overrideRepoNames(repoNames) {
for (x in repoNames) {
getElementByXpath('//*[@id="__ListRow_1-' + (parseInt(x) + 1) + '"]/div/div[2]/span/span').innerHTML = repoNames[x].replace(new RegExp('\\\\','g'), ' \\ ')
}
}
repoNames = ['Ujnotes\\Website\\Framework', 'WCode\\Website\\Framework', 'WCode\\Website\\interim', 'WCode\\Location\\interim', 'Ujnotes\\Website\\interim', 'WCode\\Location\\Paper', 'WCode\\Website\\Project', 'WCode\\Android\\Project', 'WCode\\Windows\\Project', 'WCode\\Location\\Project', 'Ujnotes\\Website\\Project'];
getElementByXpath('//*[@id="desktop-app-toolbar"]/div[1]/div/div/button').addEventListener('click', function(event) {
setTimeout(function() {
if(getElementByXpath('//*[@id="foldout-container"]') != null)
overrideRepoNames(repoNames)
}, 50);
});
This is the result:这是结果:
Here is AHK
script to automate the execution of the script snippet at launch:这是在启动时自动执行脚本片段的
AHK
脚本:
Run, "%LocalAppData%\GitHubDesktop\GitHubDesktop.exe"
winWait, GitHub Desktop
sleep, 1000
send, {CTRLDOWN}{SHIFTDOWN}i{SHIFTUP}{CTRLUP}
sleep, 2000
send, {CTRLDOWN}{SHIFTDOWN}p{SHIFTUP}{CTRLUP}
sleep, 2000
send, {BACKSPACE}
sleep, 100
send, {!}
sleep, 100
send, {ENTER}
sleep, 500
send, {CTRLDOWN}{SHIFTDOWN}i{SHIFTUP}{CTRLUP}
You have to rename directory in this Method您必须在此方法中重命名目录
How do I change the displayed name of this repository in the GitHub desktop app without having to rename the repository directory name?
如何在 GitHub 桌面应用程序中更改此存储库的显示名称,而无需重命名存储库目录名称?
You would need to upgrade GitHub Desktop to its latest revision 2.8 (Apr. 2021) :您需要将GitHub Desktop升级到其最新版本 2.8(2021 年 4 月) :
Create aliases for repositories locally
在本地为存储库创建别名
Many developers keep more than one copy of a repository in GitHub Desktop, and the way repositories are displayed makes it tricky to differentiate between them.
许多开发人员在 GitHub Desktop 中保留了多个存储库副本,并且存储库的显示方式使得区分它们变得很棘手。
In GitHub Desktop 2.8, you can create aliases for your local repositories to easily tell them apart in the list.
在 GitHub Desktop 2.8 中,您可以为本地存储库创建别名,以便在列表中轻松区分它们。
Non of the above is the right answer.以上都不是正确答案。 Only putting the name in
.git/description
(own first line) has it done for me!只有将名称放在
.git/description
(自己的第一行)中才能为我完成!
Reason: I don't why but VSCode has changed my repository names to completely wrong ones.原因:我不知道为什么,但 VSCode 已将我的存储库名称更改为完全错误的名称。 So there must be another point where GitHub Desktop takes the names.
因此,GitHub Desktop 的名称肯定还有另一个地方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.