I have a local repository (has a local remote-origin 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.
Problem is: C:\Project1\Website
& C:\Project2\Website
- both show up as Website
I want to refrain from having to have: C:\Project1\Project1-Website
I set the .git\description
file - did not work.
I set the remote origin URL
to <path>\Project-Website.git
- did not work.
I tried git clone <path>\Project-Website.git Project-Website
- did not work.
This is the mess that it causes:
To rename any repository of your GitHub account: Go to that particular repository which you want to rename. Navigate to the settings tab. There, in the repository name section, type the new name you want to put and click Rename.
On GitHub.com, navigate to the main page of the repository. Under your repository name, click Settings. Under the Repository Name heading, type the new name of your repository. Click Rename.
UPDATE: This has been resolved now - with the "Add Alias" feature.
It turns out git
itself has no provision to specify the repository name. 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
.
Also GitHub desktop
has no provision to rename the local repositories.
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]
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:
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}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With