I can't add file or change file to github.com - github

I've created an account for github,and set up ssh at home and at my workplace. now I just want to renew and add files so that I do some operation like this:
jty#CVICSE-0E662498 ~/front-end-learn (master)
$ git remote add origin git#github.com:jtyjty99999/front-end-learn.git
jty#CVICSE-0E662498 ~/front-end-learn (master)
$ git push - u origin master
ssh:github.com:noaddress associated with name
fatal: The remote end hung up unexpectedly
I failed T_T. At my workplace I used proxy to connect to Internet, does it matter? How can I solve this problem? thanks everyone cordially.

I think you are inputting the command wrong, I believe it is supposed to be this
git push -u origin master
(no space after the '-')
and you can double check the proper address by using
git remote -v
edit: you also have to use the commands commit and add to actually tell git what to push
here is more info

Related

Messed up with deploy key

When I try to push my files to the git server I faced this problem.
`~ git push
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin main
So, I've entered git push --set-upstream origin main in the terminal. It was showing up the following error.
ERROR: Permission to adivenkat05/C-Assignments.git denied to deploy key
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
So, after searching for the solution, it was that we need to upload our ssh key in the git server (Deploy Key).
I've uploaded that same key to another repository but it ended up showing me this "So, after searching for the solution, it was that we need to upload our ssh key in the git server (Deploy Key).
I've uploaded that same key to another repository but it ended up showing me this "Key is already in use".
So, it's not possible to have multiple ssh keys in a particular machine, right?
How do I tackle this problem?".
The second error is different, and refer to an authentication problem.
You can have multiple keys, a deploy one and one associated with your user account.
Create a new dedicated key, and add it to your account:
ssh-keygen -t rsa -P "" -f ~/.ssh/me
Reference it in a ~/.ssh/config file:
Host gh
Hostname github.com
User git
IdentityFile ~/.ssh/me
IdentitiesOnly yes
And your SSH URL becomes gh:me/myRepository. (no more git#github.com:...)
You can test your SSH key with ssh -Tv gh.
It it works:
cd /path/to/my/local/repo
git remote set-url origin gh:adivenkat05/C-Assignments.git
git push -u origin main

Git hub pushing to a forked repo

I'm new to github and I couldn't seem to find a solution to my problem, so bear with me a little.
I'm trying to push changes that I've made to a forked repo via command line on an ec2 ubuntu instance from aws. After making changes to my file, I committed the file I changed and then pushed it over to git:
ubuntu#ip-172-31-33-24:~/bitstarter$ git push origin master
Username for 'https://www.github.com': edasaur
Password for 'https://edasaur#www.github.com':
fatal: Authentication failed
I'm hypothesizing that this might be an issue with the fact that I'm pushing over to a forked repo because when I attempted to commit and push changes over to a repository that I started, it seemed to work. However, I'm at a loss at what to do. When I tested whether my SSH key worked via the command:
ubuntu#ip-172-31-33-24:~/bitstarter$ ssh -T git#github.com
Hi edasaur! You've successfully authenticated, but GitHub does not provide shell access.
Thanks in advance!
First, you are pushing using an https address, so any ssh settings you might have won't have any bearing on the completion of the (https) push.
Second, the right https url you should use is:
https://edasaur#github.com/edasaur/bitstarter.git
(no need for www.github.com)
(I like to put the username in the url: that is one less data to enter when pushing)
That means you can set your url with:
git remote set-url origin https://edasaur#github.com/edasaur/bitstarter.git
Third, double-check your password (and see if there is any special character in it like an '#', which might not be directly supported over an http query)
If nothing works, you can still fallback on ssh url:
git remote set-url origin git#github.com:edasaur/bitstarter.git

Authentication Failure on Github even after adding SSH key

I get fatal:Authenication Failure when I try to push code to my repo. I've added the public key on my github account as well. When I do :
ssh -i git#github.com
I get
Hi amangupta052! You've successfully authenticated, but GitHub does not provide shell access.
Can anyone help?
Thanks
That depends on the remote url you have used.
If git remote -v returns:
https://github.com/username/reponame
Then your ssh setup won't matter. But this would work:
ssh://git#github.com:username/reponame
Another cause is linked to your private key: if it is pass-phrase protected, with a special character in it, that usually don't work well.
See here for other ssh causes of failure.
To replace your remote named origin, use git remote commands:
git remote set-url origin ssh://git#github.com:username/reponame
(as explained in the GitHub help page about changing the rmeote url)
If you see::
ssh: Could not resolve hostname github.com:amangupta052:
Name or service not known
fatal: The remote end hung up unexpectedly
Try the non-scp ssh syntax:
git remote set-url origin ssh://git#github.com/username/reponame
(note the '/' instead of the ':' after github.com)
Maybe this would have worked, as commented in this blog post:
git remote set-url origin git#github.com:username/reponame
(scp-like syntax, but without the ssh:// prefix)
As I mention here, an scp syntax usually means an ~/.ssh/config file to work properly.

GitHub -> 'The remote end hung up unexpectedly'

I am trying to push a project (Calico) to GitHub, and am running into an error. I've successfully logged in via a ssh connection, and received the usual response:
Ryan#RYANLAPTOP-PC /C/inetpub/wwwroot/Calico (master)
$ ssh git#github.com
Enter passphrase for key '/c/Users/Ryan/.ssh/id_rsa':
Hi rossryan! You've successfully authenticated, but GitHub does not provide shel
l access.
Connection to github.com closed.
However, I am still receiving an error when I attempt to push the code:
Ryan#RYANLAPTOP-PC /C/inetpub/wwwroot/Calico (master)
$ git push -u github master
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
Connection abandoned.
fatal: The remote end hung up unexpectedly
I believe I've followed the instructions rather faithfully from the website, substituting 'GitHub' for 'origin' in the right areas (origin is apparently already defined, so I used a different name). I've emailed GitHub about this problem, but have received no response.
Does anyone have any other ideas?
EDIT:
Output from git remote -v:
Ryan#RYANLAPTOP-PC /C/inetpub/wwwroot/Calico (master)
$ git remote -v
github git#github.com:rossryan/Calico.git (fetch)
github git#github.com:rossryan/Calico.git (push)
origin C:/inetpub/wwwroot/Calico/ (fetch)
origin C:/inetpub/wwwroot/Calico/ (push)
git push origin master fails was about that error when using putty (instead of the packaged openssh included with msysgit). I don't think that is your case.
git - Server host key not cached is about that same error, and proposes to establish an ssh connection, which you did (and it didn't propose to add github to your $HOME/ssh/known_hosts file, so this isn't the issue either.
What you need to check is:
why are you pushing to github instead of the default name 'origin' (did you really add a remote (upstream) repo named 'github'?)
What exact address is behind the remote name 'github'. A right address for pushing would be (from GitHub man page on remote):
an ssh URL git#github.com:user/repo.git
or an https URL such like https://user#github.com/user/repo.git

cant remote add to github

This is the first commit I'm adding to git. I ave initialized git inside my directory and am trying to remote add following this command:
git remote add origin git#github.com:pvenkat/Scribble-pad.git
But I receive a fatal error telling me remote origin already exists:
fatal: remote origin already exists
Does this mean I must remove the previous remote origin? If so how do i do that? If anyone knows whats wrong please help.
You probably already have the origin defined.
You can run,
git remote rm origin
Then,
git remote add origin git#github.com:pvenkat/Scribble-pad.git
You can update the URL of your existing remote with the following command:
git config remote.origin.url git#github.com:pvenkat/Scribble-pad.git