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

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.

Related

How to change where Remote - SSH puts files

I have restrictions on the home directory of my remote machine, is there a way to change where Vscode Remote - SSH puts it's collateral files (~/.vscode, ~/.vscode-server, ...)?
I've looked through all the settings and haven't found anything that looks right
I need the ~/.vscode to be located somewhere besides home folder
I found the active feature request https://github.com/microsoft/vscode-remote-release/issues/472
To get around this for now you can link ~/.vscode-server to another folder/drive
ln -s /path/to/big/disk/.vscode-server ~/.vscode-server

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

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

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!

Post-commit hook failed (exit code 3) with output

I'm trying to call a Jenkins job remotely using a post-commit script. I'm currently committing code through Eclipse Kepler/Subversive/SVNKit Connector.
post-commit script:
if svnlook dirs-changed -r "$REV" "$REPOS" | grep -qEe '^trunk/'; then
wget --post-data="job=APS-RemoteServerAction&token=SECRET&ACTION=deploy&ASSET_NAME=POST-COMMIT-TEST&DEPLOY_ENV=DEV&REVISION=$REV" "http://my.domain.com:8080/buildByToken/buildWithParameters"
fi
Screenshot of error through Eclipse:
Important notes:
Code does get committed properly, repository browser indicates a new version
The job runs on Jenkins, the history shows that
Everytime I commit, I get this error message
I tried adding the flag --quiet, but I got the same exit code.
I'm thinking it's due to wget and posting the values?
Edit #1
I would like to point out that I'm using the Jenkins Build Authorization Token Root Plugin. I switched to a POST instead of a GET (which works) due to eventually moving onto https and keeping the token out of the URL.
I interpret the error message to mean that wget can not write a file with the name buildWithParameters in its current directory. Use wget -O - to write the output to stdout.
The error is (I think) because it's trying to download the webpage to a local dir. You just need to ping the endpoint to make jenkins build, so I used the --spider (doesn't download), --no-proxy (I was getting cached responses sometimes) and -q (don't output, cuz svn will report it).
wget --post-data="job=APS-RemoteServerAction&token=SECRET&ACTION=deploy&ASSET_NAME=POST-COMMIT-TEST&DEPLOY_ENV=DEV&REVISION=$REV" "http://my.domain.com:8080/buildByToken/buildWithParameters" --spider --no-proxy -q