git的四次元口袋:github、码云

1、配置ssh账户和邮箱

创建账户

git config --global user.name "我的姓名"
git config --global user.email "我的邮箱"

查看账户

git config --global user.name 
git config --global user.email

2、本地生成ssh密钥

邮箱为刚刚配置好的邮箱

ssh-keygen -t rsa -C "[email protected]"

按照提示进行三次回车即可

3、查看密钥

vim ~/.ssh/id_rsa.pub

 也可以在c盘下查找ssh目录

4、复制公钥到GitHub、gitlab、码云上

切记三个平台可以使用同一个公钥

5、查看密钥四否配置成功

//码云
ssh -T [email protected]
//Hi hanmeimei! You've successfully authenticated, but GITEE.COM does not provide shell access.表示连接成功 

//github
ssh -T [email protected]
//Hi hanmeimei! You've successfully authenticated, but GitHub does not provide shell access.表示连接成功。

6、建立仓库连接

    //git使用
    //(1)初次使用
        echo "# heima" >> README.md
        git init
        git add README.md // 文件夹已有内容 git add ./
        git commit -m "first commit"
        git remote add origin [email protected]:你的账户名字/仓库名字.git
        git push -u origin master
   // (2)再次使用
        git remote add origin [email protected]:你的账户名字/仓库名字.git
        git push -u origin master

7、如何将分支代码合并到master中

1.首先切换到分支;

git checkout roles

2.使用git pull 把分支代码pull下来;

git pull

3.切换到主分支;

git checkout master

4.把分支的代码merge到主分支;

git merge roles

5.git push推上去ok完成,现在 你自己分支的代码就合并到主分支上了。

git push

本次学习完毕。

发布了78 篇原创文章 · 获赞 5 · 访问量 8286

猜你喜欢

转载自blog.csdn.net/qq_36789311/article/details/105033785