- 注册完github后,配置ssh key
- 生成公私钥
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
-
cd ~/.ssh/
到本地这个目录下查看生成的公私钥,使用命令cat id_rsa.pub
把公钥粘贴到github上
image.png


-
新建github仓库
image.png
根据自己个人实际情况填写
image.png
license协议是自己情况而定。 -
本地仓库新增远端站点
image.png

git remote add github git@github.com:chenningjing/git_learning.git

- 将本地仓库push到远端github上
git push github --all
image.png
这个时候master分支被拒绝了,说远程分支包含了有些工作是本地没有的, 如果本地要和远端的做集成,要先把远端的拉下来;此时版本树如下图,我们等下观察变化

-
将远端信息拉取下来
git fetch github matser
image.png
gitk --all
image.png
-
合并分支
要把远端的master和本地master分支合并(在本地合并)

git checkout master
# 切换到master分支git merge github/master

直接进行合并会报错,因为两棵树不存在父子关系,所以要带参数
使用命令:
git merge --allow-unrelated-histories github/master

-
结果验证
image.png
- 将本地分支向远端push
git push github master
image.png
验证:这个时候远端的分支也都被有了
image.png
网友评论