Scripts to open git remote url in browsers. Look on Peerlist LaunchPad
It defaults to the origin
remote but supports passing a different remote name if needed.
- Have a Windows OS device
- Have Git installed and available in your system PATH (see Enviroment Variables)
- A valid Git repository initialized in the current directory
Paste this into PowerShell to download both scripts to your Scripts
folder:
$target="$env:USERPROFILE\Scripts"; New-Item -ItemType Directory -Force -Path $target; Invoke-WebRequest https://raw.githubusercontent.com/himanshubalani/gogit/main/gogit.bat -OutFile "$target\gogit.bat"; Invoke-WebRequest https://raw.githubusercontent.com/himanshubalani/gogit/main/gogit.ps1 -OutFile "$target\gogit.ps1"
Now paste this to add the Scripts
folder just created to Environment Variables.
$fp="$env:USERPROFILE\Scripts";$p=[Environment]::GetEnvironmentVariable("PATH","User");if(-not ($p.Split(";") -contains $fp)){[Environment]::SetEnvironmentVariable("PATH","$p;$fp","User")}
To use these scripts from any folder on your system, follow these steps:
- Download the scripts: gogit.ps1 and gogit.bat
- Move the scripts: Place the script in a directory of your choice (e.g.,
C:\Users\<YourUsername>\Scripts
). - Add the directory to your PATH: Doing this allows you to run the script from any command prompt or PowerShell window. (see Enviroment Variables)
- Press Win + S and search for "Environment Variables"
- Click "Edit the system environment variables"
- In the System Properties window, click "Environment Variables"
- Under "User variables", find and select Path, then click Edit
- Click New, and add the path to your Scripts folder (e.g., C:\Users<YourUsername>\Scripts)
- Click OK to save and close all dialogs
-
gogit
Opens the URL of theorigin
remote in your default browser. (default) -
gogit [remote-name]
Opens the specified remote -
gogit show
Lists all configured Git remotes with their URLs. -
gogit --help
Displays usage instructions and available commands.
- If no argument is provided, it defaults to
origin
- Converts SSH-style URLs (e.g.,
git@github.com:user/repo.git
) to HTTPS - Opens the repository page in your default browser
Example:
gogit
gogit dev
gogit show
gogit --help
- The script checks if the current folder is a Git repository.
- It fetches the URL for the given remote (default:
origin
). - If the remote uses SSH (
git@github.com:user/repo.git
), it converts it to HTTPS. - It strips the
.git
suffix (if present). - It opens the resulting URL in your default browser.
-
"Not a Git repository"
Make sure you're inside a folder with a.git
directory (i.e., a valid Git repo). -
"Remote not found"
Double-check the remote name by runninggit remote -v
. -
PowerShell script execution policy blocks the script
You may need to allow script execution:Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
-
Opening URL fails
Ensure you have a default browser set and you're not running in a restricted environment.
You can rename these scripts and add them to a folder in your system PATH
for easier access from any Git repo.