项目上传到github时出现的错误

来源:互联网 发布:博奥软件多少钱 编辑:程序博客网 时间:2024/05/16 15:04

本文参考了 http://blog.csdn.net/luckyyulin/article/details/21090905 感谢。

首先下载好git安装,安装过程略过。


配置Git

     (1) 首先在本地创建ssh key;
    $ ssh-keygen -t rsa -C "your_email@youremail.com"
 后面的your_email@youremail.com改为你的邮箱,之后会要求确认路径和输入密码,我们这使用默认的一路回车就行。成功的话会在~/下生成.ssh文件夹,进去,打开id_rsa.pub,复制里面的key。回到github,进入Account Settings,左边选择SSH Keys,Add SSH Key,title随便填,粘贴key。

 

 (2)为了验证是否成功,在git bash下输入:
    $ ssh -T git@github.com 
 如果是第一次的会提示是否continue,输入yes就会看到:You’ve successfully authenticated, but GitHub does not provide shell access 。这就表示已成功连上github。





可能会出现错误:

Agent admitted failure to sign using the key.
Permission denied (publickey).
解决方案:参考https://help.github.com/articles/generating-ssh-keys/

# start the ssh-agent in the backgroundeval "$(ssh-agent -s)"# Agent pid 59566ssh-add ~/.ssh/id_rsa

 (3)接下来我们要做的就是把本地仓库传到github上去,在此之前还需要设置username和email,因为github每次commit都会记录他们。
 $ git config --global user.name "your name" 
 $ git config --global user.name "your name"$ git config --global user.email "your_email@youremail.com"
 (4)进入要上传的仓库,右键git bash,添加远程地址:
  $ git remote add origin git@github.com:yourName/yourRepo.git
 后面的yourName和yourRepo表示你再github的用户名和刚才新建的仓库,加完之后进入.git,打开config,这里会多出一个remote “origin”内容,这就是刚才添加的远程地址,也可以直接修改config来配置远程地址。

 

    4.提交、上传
  (1)接下来在本地仓库里添加一些文件,比如README,
   $ git add README
   $ git commit -m "first commit" 
   (2)上传到github:
   $ git push origin master 
   git push命令会将本地仓库推送到远程服务器。
   git pull命令则相反。

   修改完代码后,使用git status可以查看文件的差别,使用git add 添加要commit的文件,也可以用git add -i来智能添加文件。之后git commit提交本次修改,git push上传到github。


上传时会出现问题:

ERROR: Repository not found.

  这个问题是因为在你推送的github账户中,并没有这个Repository。

  解决方法:

  1)登陆自己的github帐号,创建一个目录如first,再push一遍。


0 0
原创粉丝点击