Git push not working but "git clone" and SSH does - windows

I set up a Debian server that uses SSH for shell access and git repos. I created a bare repo on it and using ssh was able to clone it to my Windows 8 workstation, however when trying to push changes back to the Debian server I get the error depicted here:
Read from remote host 174.52.5.192: Connection reset by peer
fatal: sha1 file '<stdout>' write error: invalid argument
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'git#174.52.5.192:/home/git/repos/space-junk.git/'
I use this work station regularly for shell access to the same server via SSH so I know inability to access SSH isn't the problem.
Does anyone have any idea what's going wrong?

Actually, the first push should be:
git push -u origin master
That will link the local branch master to its remote tracking one origin/master
Then, after that first push, you will be able (for all the subsequent push) to do a simple:
git push
See more at "Why do I need to explicitly push a new branch?".

I got it working! It turns out the proper command was
git push origin master
The Windows version didn't have a descriptive enough error message but I got it working by switching over to Linux, which told me my command was wrong.

Related

Unable to pull and push to git via cmd

I got a problem. A am trying to learn git. I initialized my local repo, added everything, committed. I'm using atom cmd and bash, because there are some commands, that are unavailable in atom cmd. I created an ssh-key, added it and everything works fine. I am trying to synchronize everything and pull from the remote repo, but I am getting an error:
PS C:\Users\keldranase\Documents\Obsidian Vaults> git pull origin master --allow-unrelated-histories
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
At the same time, when I am doing same using bash, everything works fine:
keldranase#DESKTOP-SH6U8NC MINGW64 /c/users/keldranase/documents/Obsidian Vaults (master)
$ git pull origin master --allow-unrelated-histories
Whats the reason behind this? How to solve this problem? What am I doing wrong? Your help would be appreciated.
Screenshot:
Your SSH key is not loaded. You need first to start the ssh client and then add the ssh key, you can find more information here. And here you can find some useful troubleshooting information for your error and other issues you might experience with SSH - Error Permission Denied.

Pushing commits to an SSH-cloned repo via VS Code on WSL returns "Host key verification failed" - it's ok on HTTPS

I'm on a Windows 10 machine and I have both Git Bash and Ubuntu for Windows Subsystem for Linux (WSL) installed. When I use GitHub's official desktop app to clone a repo via HTTPS everything works fine and I can push my commits via Visual Studio Code with no problems whatsoever. I then try to clone a repo via SSH with Hyper (WSL Bash) and get this:
The authenticity of host 'domain.com (a.b.c.d)' can't be established.
RSA key fingerprint is XX:XX:...:XX.
Are you sure you want to continue connecting (yes/no)?
After answering yes and openning that repo in VS Code and try to push my new changes to GitHub, I get this error:
Git: Host key verification failed.
And this is what I get as Git Log in Output:
Host key verification failed.
fatal: Could not read from remote repository.
I have set up my SSH key on WSL using this method and I didn't set up any passphrase. I tried this on my brother's PC which is exactly set up like mine and it worked just fine. I would appreciate any help!
UPDATE: I typed ssh -T git#github.com in Hyper and got this as an answer: You've successfully authenticated, but GitHub does not provide shell access.
P.S. I'm a newbie in programming and stackoverflow, so please be concise and give me step by step instructions. The more you use technical terms, the more I'll probably get lost!
Try first, for that new push, to do it in command line:
cd c:\path\to\local\repo
git status
git log
git remote -v
git push -u origin master
Make sure that:
git status is clean (no pending changes)
git log shows you at least one commit
git remote -v shows you as origin the URL of your remote GitHub repository
(as an SSH URL git#github.com:<you>/<yourRepo>)
Then push, and go back to VSCode.
Should be faster than the other solution:
In vscode open a new terminal of type "Command Prompt"
Run: git push and accept the new key when prompted.
This will store the remote key for future use.

Git connect using ssh on windows

I have read some questions around but still didn't found the solution to this problem
I have git on windows and I want to connect to github using ssh.
Following this tutorial https://help.github.com/articles/generating-ssh-keys
I have successfully setup my keys
If I open a git-bash and try to ssh github I am able to connect, so this works
ssh -T git#github.com
Hi username! You've successfully authenticated, but GitHub does not
provide shell access.
this means that git-bash actually sees my keys. However if I try to do a push
git push origin master
git prompts me for username and password
Thank you for your help
EDIT: solved by using the git protocol instead of the http protocol, my fault
so replace this
https://github.com/_user_/_repository_.git
whit this
git#github.com:_user_/_repository_.git
in the remote link
No need to remove/add, just do something like this:
git remote set-url origin git#github.com:username/repo.git
You probably cloned a remote that uses the https protocol, rather than the git protocol. You need to redefine your remote for origin.
# Change this as needed.
github_username="$LOGNAME"
# Replace your remote, then push.
git remote rm origin
git remote add origin "git#github.com:${github_username}/${PWD##*/}.git"
git push --tags --set-upstream origin master

Git remote server Push fails

After cloning a Git repo from my remote server, I have committed some changes on my local copy. I'd like to push these changes back to the remote server, but I'm getting an error message that yields no useful information:
fatal: read error: Invalid argument
(Ps. both the server and the local repo are running in Windows environments)
I have tried:
git push
git push origin
git push origin master
A push through the GUI version of GIT yields the same useful error message.
EDIT
After setting the Environment variable GIT_TRACE=1, I get slightly more output:
C:\repo>git push --verbose
setup: git_dir: .git
setup: worktree: C:/repo
setup: cwd: C:/repo
setup: prefix: (null)
trace: built-in: git 'push' '--verbose'
Pushing to git://MYSERVER.MYCOMPANY.net/repo
fatal: read error: Invalid argument
Any thoughts?
Looks like you're running in a plain cmd.exe terminal instead of msysgit's bash terminal. Much of git relies on shell scripts; thus, you need to run in a bash terminal instead of cmd.exe.
Are you sure the server is configured correctly, has your SSH key, etc? Did you home-brew the Git server or is this something like git-hub / assembla ?

Git push command not working with msysgit setup

I installed GIT onto my windows 2k8 server following these directions: http://code.google.com/p/tortoisegit/wiki/HOWTO_CentralServerWindowsXP
All commands work fine except the "push" command. I get this error:
git.exe push -v "origin" master:master
git: '/path/to/repo' is not a git command. See 'git --help'.
Pushing to user#ipaddress/path/to/repo
fatal: The remote end hung up unexpectedly
Does anyone know how to fix this?
It looks like the remote origin is not set up correctly.
I recommend re-creating that remote, either by renaming it or deleting it and making a new one:
git remote rename origin origin_backup
git remote add origin ssh://user:pass#address/path/to/repo.git
Then try again, preferably with a fetch before you push.
What protocol are you using? If git://, then make sure there is a Git daemon listening for connections. If ssh://, make sure you have ssh access and write permission on the appropriate directory tree.
Another possibility is that the server and client are running different versions of Git. It could cause problems if one is running a version that expects commands in the format git cmd and the other expects git-cmd.
First check, if your plain SSH access to 5.16.217.81 is working: is
ssh 5.16.217.81
able to open a connection to the host?
If that is successful, ensure that you specify the path to your repo in a way your SSH server understands. In the HowTo, the path is specified different from the path you typed:
5.16.217.81/d/private/test/ (your path) vs.
<server>:d:/DeeDriveRepos/Repo2
Obviously, the CopSSH server wants colons to separate the drive letter from the host, so that your URL should be 5.16.217.81:d:/private/test/.
If you used Cygwin, your URL would be 5.16.217.81/cygdrive/d/private/test/
My pushes work for msysgit version 1.6.5 but not for 1.7.x

Resources