一、远程仓库
1、登录GitHub,创建一个新的仓库

2、创建本地仓库和github仓库关联
git remote add origin git@github.com:【GitHub账号名】/learngit.git
3、推送master分支:
第一次:git push -u origin master
之后:git push origin master
遇到的坑:
1、添加远程库时,提示

解决:https://blog.csdn.net/zhoucheng05_13/article/details/52831703
2、提示

解决:本地库和github库没有简历密钥对
https://blog.csdn.net/u013894429/article/details/78960813
二、从远程库克隆
1、创建带readme.md文件的新的仓库

2、克隆
git clone git@github.com:账号名/gitskills.git
3、多人协作
-查看远程库信息,使用git remote -v;
-本地新建的分支如果不推送到远程,对其他人就是不可见的;
-从本地推送分支,使用git push origin branch-name,如果推送失败,先用git pull抓取远程的新提交;
-在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致;
-建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name;
-从远程抓取分支,使用git pull,如果有冲突,要先处理冲突。
4、rebase操作可以把本地未push的分叉提交历史整理成直线
5、配置git颜色:
git config --global color.ui true
6、配置别名:
git config --global alias.co checkout
网友评论