github 入门

环境 ubuntu 16.04
git version 2.7.4

#安装Git
wen@wen:~$ sudo apt-get install git  
#生成ssh密钥
wen@wen:~$ ssh-keygen -t rsa -C "865015063@qq.com"
#
wen@wen:~$ nautilus .ssh
#测试链接
wen@wen:~$ ssh -T git@github.com
#配置Git的配置文件,username和email:
git config --global user.name "your name"   //配置用户名  

git config --global user.email "your email" //配置email   

上传库

#创建测试目录
wen@wen:~$ mkdir runoob
wen@wen:~$ cd runoob
#创建文件
wen@wen:~/runoob$ echo "#菜鸟哦啊测试" >> README.md
#初始化
wen@wen:~/runoob$ git init
#选择要添加进仓库的文件:(所有 add . )
wen@wen:~/runoob$ git add README.md
#添加备注
wen@wen:~/runoob$ git commit -m "添加 README.md 文件"
#上传
#git remote add origin git@github.com:XXX/XXX.git
wen@wen:~/runoob$ git remote add origin https://github.com/wenjayliu/runoob.git
wen@wen:~/runoob$ git push -u origin master

本地更新修改

$ git fetch origin
$ git merge origin/master
Updating 0205aab..febd8ed
Fast-forward
 README.md | 1 +
 1 file changed, 1 insertion(+)

一些可能遇到的问题解决:

如果输入
$ git remote add origin git@github.com:djqiang(github帐号名)/gitdemo(项目名).git
提示出错信息:
fatal: remote origin already exists.

解决办法如下:
1、先输入
$ git remote rm origin

2、再输入
gitremoteaddorigingit@github.com:djqiang/gitdemo.git3 git remote rm origin 还是报错的话,error: Could not remove config section ‘remote.origin’. 我们需要修改gitconfig文件的内容
4、找到你的github的安装路径,我的是
C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\etc
5、找到一个名为gitconfig的文件,打开它把里面的[remote “origin”]那一行删掉就好了!
如果输入
sshTgit@github.comPermissiondenied(publickey).keysshgithub1 ssh-agent,
再输入
sshadd /.ssh/idkey2sshadd /.ssh/idkeyCouldnotopenaconnectiontoyourauthenticationagent.keyGitGuisshkeysshsshaddusertoken3idrsa.pub git push origin master
提示出错信息:error:failed to push som refs to …….
解决办法如下:
1、先输入 gitpulloriginmaster//github2 git push origin master
3、如果出现报错 fatal: Couldn’t find remote ref master或者fatal: ‘origin’ does not appear to be a git repository以及fatal: Could not read from remote repository.
4、则需要重新输入
gitremoteaddorigingit@github.com:djqiang/gitdemo.git使git makdir ~/hello-world //创建一个项目hello-world
cd /helloworld// git init //初始化
touchREADME git add README //更新README文件
gitcommitmfirstcommit//firstcommit git remote add origin git@github.com:defnngj/hello-world.git //连接远程github项目
$ git push -u origin master //将本地项目更新到github项目上去

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值