首页 技术 正文
技术 2022年11月21日
0 收藏 865 点赞 4,711 浏览 901 个字

第一次接触git是使用git来提交自己的github的代码,在new repository之后,github会给出一些操作示例。

示例如下:

…or create a new repository on the command line

echo "# hello" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:XXXX/hello.git
git push -u origin master

…or push an existing repository from the command line

git remote add origin git@github.com:XXXX/hello.git
git push -u origin master

…or import code from another repository

You can initialize this repository with code from a Subversion, Mercurial, or TFS project.

如果你是第一次使用git来提交github在执行

git push -u origin master

会报错Permission denied (publickey)。

解决方案:

1.(在本地建立自己的SSH key对,并将公钥上传到github就行了。)在git上执行

ssh-keygen -t rsa

之后会提示输入一些东西,直接按回车就好了(反正我是如此)

2.执行完上述操作后,会出现

使用git管理github上的代码

说明生成了SSH Key到本地文件.ssh/id_rsa.pub(我的在c/Users/qin/.ssh/id_rsa)中,用记事本打开,并将里面的内容复制到粘贴板上。

3.打开github的Settings,

使用git管理github上的代码

找到SSH and GPG keys进入后添加点击New SSH key

其中title不重要随意填就好了,将复制的内容拷贝到key中。

如果不出意外的话,现在可以进行提交了。

参考文档:http://jingyan.baidu.com/article/a65957f4e91ccf24e77f9b11.html

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,082
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,557
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,406
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,179
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,815
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898