How can I start GitKraken from the command line with a Git repository path on Windows?

Viewed 4122

I'd like to create a bunch of shortcuts to open Git repository

GitKraken starts like this:

C:\Users\<username>\AppData\Local\gitkraken\Update.exe --processStart "gitkraken.exe"

I tried to just add the path like this, but nothing happened:

C:\Users\<username>\AppData\Local\gitkraken\Update.exe --processStart "gitkraken.exe  \"C:\<path to repo with spaces>\MyRepo1\""
C:\Users\<username>\AppData\Local\gitkraken\Update.exe --processStart "gitkraken.exe  \"C:\<path to repo with spaces>\MyRepo2\""
C:\Users\<username>\AppData\Local\gitkraken\Update.exe --processStart "gitkraken.exe  \"C:\<path to repo with spaces>\MyRepo3\""

There could be multiple problems:

  1. GitKraken might not support a path as parameter. Didn't find any documentation when I googled for "gitkraken from command line with repository path as parameter"
  2. Quotes within quotes might be wrong, but I think it's correct: Command line passing quotes within quotes
  3. The command line syntax might be different, but as mentioned above, I didn't find any documentation. I tried "-p" because I saw something similar while googling but it didn't work either C:\Users\<username>\AppData\Local\gitkraken\Update.exe --processStart "gitkraken.exe -p \"C:\<path to repo with spaces>\MyRepo1\""
2 Answers

GitKraken uses the Squirrel.Windows project for installation and update management for it's Windows installs. So the update.exe that is running when you click on the shortcut labeled "GitKraken" is running the Squirrel.Windows process that checks for and downloads updates and then runs the newest version of GitKraken. Once that check is complete, it launches the GitKraken.exe and starts the program.

To solve your issue you will need to pass a CLI option through the Squirrel call into the the gitkraken.exe. You are correct that gitkraken.exe accepts the -p | --path option for the repo to open at launch (e.g. gitkraken.exe -p "\path\to\repo"). If you run it from the app folder directly, you can see the options available at gitkraken.exe --help. Luckily, there are a couple of as-yet undocumented options you can pass that do the pass-through for you (referenced here) so your custom shortcut could now be:

..\Update.exe --processStart "gitkraken.exe" --process-start-args="--path \"d:\path with spaces\to\repo\""

Re: persistence through GitKraken executable updates- OP has confirmed in comments after GitKraken updated to v4.2 that the shortcuts they set up continued to work!

This is what working for me in Ubuntu Desktop

Define it

gkk() { # gkk aka gitkraken
    repo_d=$1
    if [ -z $repo_d   ]; then repo_d=`pwd`; fi
    if [ ! -d $repo_d ]; then echo "Invalid :repo_d at $repo_d"; exit 1; fi
        /usr/bin/gitkraken -p $repo_d &
}

Use it

cd /path/to/your/repo
gkk

Note, calling the command again on 2nd repo will NOT work!

The workaround I can think of is to close and reopen GitKraken app

Related