Git的使用--如何将本地项目上传到Github

//==========Git的使用--如何将本地项目上传到Github=====以下为总结笔记,不适合初学者================ 

 初学者请移步大牛网站 Git - Book

初次运行 Git 前的配置 - Gitee.com 

//git config

git config --global user.name 932432866

git config --global user.email 932432866@qq.com 

git config --global pull.rebase true     

敲git config --list确认

 //常用

git init          //把这个目录变成Git可以管理的仓库
git add README.md //文件添加到仓库
git add .      //不但可以跟单一文件,还可以跟通配符,更可以跟目录。一个点就把当前目录下所有未追踪的文件全部add了 
git commit -m "first commit" //把文件提交到仓库
git remote add origin git@github.com:932432866/MCGS.git //关联远程仓库
git push -u origin master //把本地库的所有内容推送到远程库上   以后再上传就不需要 -u 参数了

//创建本地SSH KEY 切换到c/Users/Jokey/

ssh-keygen -t rsa -C "932432866@qq.com"
1)路径确认,直接按回车存默认路径即可
2)直接回车键,这里我们不使用密码进行登录, 用密码太麻烦;
3)直接回车键

4)   添加的是“id_rsa.pub”里面的公钥

//在github网页配置SSH KEY
1)setting 略
//能测通?Hi 932432866! You've successfully authenticated, but GitHub does not provide shell access.
ssh -T git@github.com

//将本地的仓库关联到github上
git remote add origin https://github.com/932432866/MCGS
//把代码上传到github仓库
git push -u origin master

PS:如果仍然无法成功拉代码,提示:

sign_and_send_pubkey: signing failed: agent refused operation 10072800@gerritro.zte.com.cn: Permission denied (publickey). fatal: Could not read from remote repository.

在终端中再输入:ssh-add

//遇到如下问题

$ git push -u origin master
To https://github.com/932432866/MCGS
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/932432866/MCGS'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

//解决  

$ git pull --rebase origin master
From https://github.com/932432866/MCGS
 * branch            master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
Applying: first commit
Applying: add pictures

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值