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

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:
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"
Quotes within quotes might be wrong, but I think it's correct: Command line passing quotes within quotes
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\""

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

Set global environment variables in VS Code with remote-ssh

I have the case that I need to use VS Code installed on Windows 10 and run it with the extension Remote - SSH on a RHEL 7.x.
The default RHEL 7.x runs with git 1.8.x. I have installed a newer git version but this is not in the default $PATH environment.
I have found this instructions https://code.visualstudio.com/docs/remote/wsl#_advanced-environment-setup-script which describe how to set the environment variables specifically for VS Code when usind WSL.
If you want to run additional commands or modify the environment this can be done in a setup script ~/.vscode-server/server-env-setup
This does seem to work only if you use WSL. Why does this not work with the Remote - SSH extension?
My special case is that I only want and need the git>=2 while usind VS Code. When I am connected regularly via ssh I would like and need the OS default tools and settings.
This gives me the special request that I don't want to edit the ~/.bashrc, ~/.cshrc or any other user environment files.
I would like to be able to edit the environment for VS Code only. Some kind, maybe like:
#!/bin/bash
export PATH=/opt/rh/rh-git29/root/usr/bin\:$PATH
export LD_LIBRARY_PATH=/opt/rh/httpd24/root/usr/lib64:$LD_LIBRARY_PATH
...
#!/bin/csh
setenv PATH /opt/rh/rh-git29/root/usr/bin\:$PATH
setenv LD_LIBRARY_PATH /opt/rh/httpd24/root/usr/lib64:$LD_LIBRARY_PATH
...
Is there anything I have not found yet where I can make my requests to work or would this be some kind of request to the VS Code Team?
Regards.
I think I found the solution in this issue comment and the follow-up response:
When vscode-server initially starts, it uses a login shell, sourcing .profile in your home directory.
However, any following interactive shells started through VS Code are non-login shells and thus only source .bashrc
A complication in fiddling with this is that vscode-server apparently caches the environment during its lifetimes, so changes to these dotfiles don't become visible until the server is restarted.
I have a better solution to minimize the proxy scope
export http_proxy=<proxy here>
export no_proxy=<no proxy here>
while IFS= read -r _file; do
if ! grep -s -q "export http_proxy=" "${_file}"; then
sed -i -e "/^ROOT/i export http_proxy=${http_proxy}" -e "/^ROOT/i export https_proxy=${http_proxy}" -e "/^ROOT/i export no_proxy=${no_proxy}" "${_file}"
fi
done < <(find ~/.vscode-server/bin -type f -name "server.sh")

Running .sh file on Windows 10 command prompt using cygwin

I am trying to change the author name of the pushed commits on GitHub. I am following the instructions here step by step: https://help.github.com/articles/changing-author-info/#platform-windows but I am stuck at step 3. I am currently using the command prompt on Windows to do it.
#!/bin/sh
git filter-branch --env-filter $' OLD_EMAIL=“yongjeffrey#hotmail.com" CORRECT_NAME=“Jeffrey Yong" CORRECT_EMAIL=“jeffreyyong10#gmail.com" if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" fi if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ] then
export GIT_AUTHOR_NAME="$CORRECT_NAME" export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL" fi ' --tag-name-filter cat -- --branches --tags
So I literally copied and pasted the code above in my command prompt and pressed enter but it seems like there's an error. I already have Cygwin installed and I am wondering what is the best way to run the code above.
Create a file named shellpro.sh with the above code in your project directory
Open cygwin
Browse to the project directory using cd command
Type bash shellpro.sh to execute your script
Or you can simply create the file in the project folder and double click it to execute it with git-bash (CygWin in windows)
I realize this is somewhat ancient but I hit this issue. Git for Windows's bash environment on Windows 10 is a custom Cygwin environment (it seems).
I did the following to get some information on how Git sees it's environment when inside filter-branch:
git filter-branch --env-filter "printenv; echo" -- HEAD~..HEAD
This shows all sorts of handy paths like OLDPWD. But I think it's safest to put your script somewhere in your PATH.
So let's say %USERPROFILE%\bin is in your path go and you put your script in %USERPROFILE%\bin\filterscript.sh
#!/bin/bash
OLD_EMAIL="yongjeffrey#hotmail.com"
CORRECT_NAME="Jeffrey Yong"
CORRECT_EMAIL="jeffreyyong10#gmail.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ] then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
You can then invoke it like this:
git filter-branch --env-filter "source filterscript.sh" --tag-name-filter cat -- --branches --tags
Note the use of source. The script needs to be sourced otherwise the environment changes will be lost with the child shell executing the script terminates. Sourcing makes the sh instance that will later execute the commit get the environment changes. It's particularly painful if source is omitted because when debugging it seems that the script is indeed executing (and it is) but not in the right shell.

Atlassian SourceTree custom action contrast

After checking out a new branch, I wanted to stop tracking of files like .classpath via Atlassian SourceTree (Version 1.4.0.0). I created a custom action with the details below:
Then, from the "Working Copy changes" panel, I selected a file, right-clicked on it and tried to execute "assume unchanged" custom command. However, I got this totally "scrimpy" error message:
I copied the full command in the error message above and tried to execute it from the command line:
Interestingly, it worked.
Can someone tell me why this custom action didn't work at first place via right clicking and selecting from the menu?
This is interesting. I just noticed this issue on my own setup when a previously working git-based command now no longer worked. I assume something has changed in the more recent version of SourceTree. I believe the issue is now invoked commands won't get the complete environment setup configured just as one might expect when opening a terminal from SourceTree. The Completed with errors message is a result of the command not being found.
For my own setup, I work around this issue by building my custom actions with the cmd process. For example:
Caption: Full Index Patch for Selected Commit
Script to run: cmd
With parameters:
/c %LOCALAPPDATA%\Atlassian\SourceTree\git_local\bin\sh.exe --login -i -c 'git format-patch --full-index -1 $SHA'
Another example:
Caption: Full Index Patch for Working Index
Script to run: cmd
With parameters:
/c %LOCALAPPDATA%\Atlassian\SourceTree\git_local\bin\sh.exe --login -i -c ^"git diff --full-index --cached > patch.diff^"
(these examples assume you're using the embedded Git in SourceTree)
Using SourceTree 1.6.12 and Git 1.8.3.
Check if $FILE represents the full complete path of the file you selected.
It seems to be presented that way in "Custom actions – more power to you" (Feb. 2012, when custom actions were introduced to Atlassian Source Tree 1.3+).
If that is the case, using $FILE instead of C:/Repository/$FILE should be enough.
I recently got some custom actions in Windows with SourceTree Custom Action:
git stash + pull + unstash in Windows
Script to run: cmd
Parameters: /c %LOCALAPPDATA%\Atlassian\SourceTree\git_local\bin\sh.exe -c -e 'alias git=/c/Users/%username%/AppData/Local/Atlassian/SourceTree/git_local/cmd/git.exe; git stash; git pull --rebase; git stash pop'
This handles if you have multiple versions of git installed, and exits early if it fails mid-way.
git stash + pull + unstash in MacOS
The rough equivalent in MacOS looks like:
Script to run: /path/to/stash_unstash.sh
Parameters: $REPO
stash_unstash.sh
#!/usr/bin/env bash
cd $1
git stash && git pull --rebase && git stash pop
macOS - Custom Action:
Script to run: /bin/bash
Parameters:
cd $REPO && git stash && git pull && git stash pop
cd $REPO && git stash && git pull --rebase && git stash pop

'ssh' is not recognized as an internal or external command

I have been trying to deploy my app into the Fortrabbit servers using the command line. I'm using windows. Here is what I tried :
C:\projects\riwaya>git remote add fort git#git2.eu1.frbit.com:riwaya.git
C:\projects\riwaya>git remote fort
C:\projects\riwaya>ssh u-riwaya#ssh2.eu1.frbit.com
'ssh' is not recognized as an internal or external command, operable program or batch file.
I have watched This Laracast Video and did the same as Jeffrey but it doesn't work ...
Can somebody help ?
Actually you have 2 problems here: First is that you don't have ssh installed, second is that you don't know how to deploy
Install SSH
It seems that ssh is not installed on your computer.
You can install openssh from here : http://openssh.en.softonic.com/download
Generate your key
Than you will have to geneate your ssh-key. There's a good tutorial about this here:
https://help.github.com/articles/generating-ssh-keys#platform-windows
Deploy
To deploy, you just have to push your code over git. Something like this:
git push fort master
If you get permission denied, be sure that you have put your public_key in the dashboard in the git tab.
SSH
The ssh command gives you access to your remote node. You should have received a password by email and now that you have ssh installed, you should be asked for a password when trying to connect. just input that password. If you want to use your private ssh key to connect to your server rather then typing that password, you can follow this : http://fortrabbit.com/docs/how-to/ssh-sftp/enable-public-key-authentication
For Windows, first install the git base from here: https://git-scm.com/downloads
Next, set the environment variable:
Press Windows+R and type sysdm.cpl
Select advance -> Environment variable
Select path-> edit the path and paste the below line:
C:\Program Files\Git\git-bash.exe
To test it, open the command window: press Windows+R, type cmd and then type ssh.
First of all Go to browser and install openssh here: https://github.com/PowerShell/Win32-OpenSSH/releases
Next step, extract rar file into folder and then copy and paste it in your drive.
after that run command: ssh it should work.
Next step is right click on shh in openssh folder and go to properties. Copy the path
and paste it in system variables in edit environment variables.
It will work fine.
TLDR, add this to settings.json
"terminal.integrated.env.windows":
{
"PATH": "C:/Windows/System32/OpenSSH",
},
Just found a case when the integrated terminal hasn't recognized 'ssh' as command, but you tried 'ssh' that was working on external terminals like CMD, git-bash.
That means you didn't add PATH variable to your integrated terminal.
If anyone looking for solution even now, here is how I did it for my Windows 10 machine.
Start > type 'Manage Optional Features'
Add Feature [+]
Look for OpenSSH client & select & install
After successful installation, open (close if already opened) powershell or command prompt and run ssh!

Unable to push using Eclipse/Egit to repository over SSH with git-receive-pack and git-upload-pack set

The title pretty much says it all:
I'm using Eclipse (Juno SR2) with the EGit plugin (2.2.0).
I have a remote repository set up using SSH, and because gitd is not setup on the remote, and because the git tools are not on the path, I have the the following settings in the config file:
[remote "origin"]
url = ssh://moi#fully.qualified.host/home/colleague/repo.git
fetch = +refs/heads/*:refs/remotes/origin/*
uploadpack = ~colleague/bin/git-upload-pack
receivepack = ~colleague/bin/git-receive-pack
Doing a plain git push from the command line displays the server's security warning then prompts me for my ssh password, then pushes flawlessly.
However inside Eclipse, I get a popup with the server warning, then I am prompted for my password as before, all appears well, then the final confirmation with the list of commits pushed is empty with an error at the top of
ssh://moi#fully.qualified.host/home/colleague/repo.git: push not permitted
I'm inside a new branch that has not been pushed to the remote as yet, if that makes any difference.
Anyone seen this before?
For anyone that follows down the same rabbit hole after me...
I have found a workaround. You can't set the location of the receive and upload packs in the repository config, so this has to be removed from your config:
[remote "origin"]
receivepack = /blah/bin/git-receive-pack
uploadpack = /blah/bin/git-upload-pack
I'm using the Bash shell remotely, and at the start of .bashrc before it exits when the shell is non-interactive, the location gets added to the path like so:
# If not running interactively, most of what follows is not worth doing
if [ -z "$PS1" ] ; then
# Make sure my extra stuff is on the path even in non-intaractive shells (I'm looking at you SSH!)
export PATH=/blah/bin:$PATH
return
fi
I can now push from either the local command line or via Eclipse/EGit. But of course I have reduced the security of my non-interactive shells as a compromise.