github仓库命令行下的使用-ubuntu系统

来源:互联网 发布:怎么成为java高级编程 编辑:程序博客网 时间:2024/05/23 13:03

在ubuntu系统命令行下如何对自己的github仓库进行下载和上传呢?
1·首先检查电脑是否通过github仓库的sshkey认证

ssh -T git@github.com

如果出现:Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.
没问题,进行下一步,但是如果你没有添加过这台主机的sshkey,就会出现:

Warning: Permanently added 'github.com,1' (RSA) to the list of known hosts.Permission denied (publickey).

这是时候首先:

ssh-keygen -t rsa 然后一路回车cat ~/.ssh/id_rsa.pub复制里面的内容,如果你是在服务器上跑的话,建议用mobaxterm的编辑器把文本打开复制其中的内容

然后进入自己的github仓库的设置:
选择添加develop key
把复制的内容加到key里面去就行。
然后再次在本机运行ssh -T git@github.com即可成功
2·通过认证能够连接github之后首先下载云端的数据库:
这里写图片描述
复制自己仓库这里的链接,假如是git@github.com/video-caffe.git

运行git clone git@github.com/video-caffe.git这时候就会开始下载仓库到本地,文件在当前目录下自动生成文件夹名为video-caffe

然后你进入video-caffe文件夹

git init  #这个命令会在当前目录下创建一个.git文件夹。 git add .  #这个命令会把当前路径下的所有文件,添加到待上传的文件列表中。 git commit -m "xxxxx"  git remote add origin git@github.com:xuhongxin/deom.git  git pull origin master  #下载所有git push -u origin master  #上传所有

但是一般第一次执行的时候还会提示错误

*** Please tell me who you are.Run  git config --global user.email "you@example.com"  git config --global user.name "Your Name"to set your account's default identity.Omit --global to set the identity only in this repository.

这时候按照提示输入

git config --global user.email "1234@qq.com"#你自己的注册github邮箱git config --global user.name "Your Name" #名字随便写,如果是开源项目,名字最好实名

其实是ubuntu下的话,可以将上面的文件分别写成upload.sh和download.sh
upload.sh:

#!/usr/bin shgit init  #这个命令会在当前目录下创建一个.git文件夹。 git add .  #这个命令会把当前路径下的所有文件,添加到待上传的文件列表中。 git commit -m "xxxxx"  #git remote add origin git@github.com:xuhongxin/deom.git  #git pull origin master  #下载所有git push -u origin master  #上传所有

download.sh:

#!/usr/bin shgit init  #这个命令会在当前目录下创建一个.git文件夹。 git add .  #这个命令会把当前路径下的所有文件,添加到待上传的文件列表中。 git commit -m "xxxxx"  #git remote add origin git@github.com:xuhongxin/deom.git  git pull origin master  #下载所有#git push -u origin master  #上传所有

下次上传的时候直接 sh upload.sh就可以了,不过注意的是这样你的github仓库上还会出现多余的upload.sh和download.sh文件

1 0