Git基础总结

1.常用命令

git clone #github仓库中的项目克隆, 无法pull其他仓库代码
git fork #将其他仓库复制到自己的github

注意:如果我们想要修改他人github项目的话,我们直接git clone代码到本地是不能pull的,所以我们使用fork,先把代码复制到自己的github仓库,然后git clone到本地修改,然后在提交pull(这里的pull是pull到自己github仓库了,我们自己的github仓库中的代码是fork源的一个分支),这时候我们想要把修改的代码提交给他人的话,就可以在自己github上pull,等其他人看到后就可以把代码做一个合并
git config [--global] core.autocrlf false
git config [--global] user.name xxx
git config [--global] user.email xxx
git remote add
git config credential.helper store
git config [--global] commit.template xxx

2.github问题

2.1从github上clone仓库时报错:

$ git clone git@github.com:northpolecan/datawarehouse.git
Cloning into 'datawarehouse'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

解决步骤
客户端生成ssh-key

ssh-keygen -t rsa -C "youremail@example.com"

一路回车,生成rsa文件


接着在再执行, 报错

ssh -v git@github.com
....
debug1: No more authentication methods to try.
git@github.com: Permission denied (publickey).

在终端再执行以下命令,生成ssh-key

ssh-agent -s 

配置服务端

打开你刚刚生成的id_rsa.pub,将里面的内容复制,进入你的github账号,在settings下,SSH and GPG keys下new SSH key,然后将id_rsa.pub里的内容复制到Key中,完成后Add SSH Key。


image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容