Create Git Repos directly from the UI
I was surprised to see that GitButler doesn't support creating repositories directly from the client. I only have the ability to add a local project (already initialised git repo). It would be great if we can have a similar UI to Github Desktop to create a new repository, with (Name,Description, localpath, gitignore, license, readme)...
Currently I'm using this PS script. It can be integrated to Explorer/XYplorer/DOpus context menu. Also you can open it in FlowLauncher using .\script.ps1 {current_path} built-in query. Or you can create Powershell shortcut to run it from Desktop, Mydockfinder, ..., other docking apps...
I deleted GitHub desktop after the script was created.
Thanks for the suggestion, I can see how this would be needed to support a full dev workflow.
For completeness, here is the modal to create a new repository in GitHub Desktop:
Also, for posterity, here is the script:
# Ensure the script stops on any error
$ErrorActionPreference = "Stop"
Set-Location -Path $args[0]
function Initialize-GitRepository {
git init
git add .
git commit -m "Initial commit"
}
function Create-GitHubRepository {
param (
[string]$name,
[string]$desription
)
gh repo create $name --description $desription --private --source . --remote upstream --push
}
# Main script
try {
# Get the current directory name to use as the repository name
$currentPath = Get-Location
$currentDirectory = Split-Path -Leaf (Get-Location)
$desription = "Repository created from the $currentDirectory dir"
Initialize-GitRepository
Create-GitHubRepository -name $currentPath -desription $desription
$url = git config --get remote.upstream.url
Set-Clipboard -Value $args[0]
Write-Host "Repository created from the $currentDirectory dir"
Write-Host "URL: $url"
} catch {
Write-Error "An error occurred: $_"
}
This ability would be really useful. For example I use GitButler when I want to see changes in different configurations in different directories. Directories constantly have to be added to GH...
I do not recommend using GH desktop for two reasons:
- You cannot create a repository in an existing directory with files.
- You can't merge opened PR's.
For all other features, there is GitButler :)
I definitely see a future where you would type gb . or just gb and it will pop open a GitButler window on the repository in the current working directory.
That would be very convenient to many people that previously used (and still use) the terminal.
UI option and terminal-esque option, and right click context menu would all be great additions. Personally, I prefer the UI option and right click context menu option. considering Git Butler provides a nice UI experience it only makes sense to provide ui based solutions. But freedom of choice is best in these circumstances. All 3 would be together would be great.
However, One thing I'm interested in is how/if butler can handle multiple GitHub accounts. For example i have my work github account an my personal github account with their own repos. I would really like to just be able to swap between them and have butler remember the repos locally on my machine for each account.
If butler does support this or intends to in the future then creating new repos would need to also include some way to determine under what git account the repo should be made under wouldn't it? Or maybe it's generically made under no account but the moment you try to push you need to choose what account your pushing/linking the repo to?
Thanks again for bringing this up - supporting and switching between multiple GitHub accounts is a very interesting feature and it would be great to have.
Getting to it could be achieved by being able to set some 'id' for any GitHub login, for that we'd need a UI concept CC @PavelLaptev . That id could then be store in the Git configuration, which would allow users to use Git mechanisms to change these depending on remote URLs for example.
Finally, GitButler would use these IDs as a part of the name it uses to store credentials in the system keychain, so each can have their own place. CC @krlvi .
I am finding this interesting because GitButler already uses the Git configuration for some values, like whether signing is permitted and could meaningfully expand on this. Maybe the UI would even have a 'concept' for it so users could know which Git configuration is behind that - right now it's kind of hidden and not easy to discover.