git学习记录三

一, 添加远程仓库

    1.要关联一个远程仓库,使用命令git remote add origin https://github.com/username/learngitt.git

    2.关联后,使用命令git push -u origin master 第一次推送master分支的所有内容

    3.从后,每次本地提交后,只要有必要,就可以使用命令git push origin master 推送最新修改;

二,从远程库克隆

      1.要克隆一个仓库,首先必须知道仓库的地址,然后使用git clone 地址 命令克隆

      2.git 支持多种协议,包括https, 但是通过ssh支持的原生git协议速度最快

三,创建与合并分支(git 鼓励大量使用分支)

      1.查看分支:git branch 

       2.创建分支:git branch <name>

       3.切换分支:git checkout <name>

       4.创建+切换分支:git checkout -b <name>

       5.合并某分支到当前分支:git merge <name>

       6.删除分支:git branch -d <name>

四,解决冲突

       1.当Git无法自动合并分支时,就必须首先解决冲突。解决冲突时侯,再提交,合并完成。

       2.解决冲突就是把Git合并失败的文件手动编辑为我们希望的内容,在提交。

       3.用 git log --graph 命令可以看到分支合并图

git log --greph --pretty=oneline --abbrev-commit

猜你喜欢

转载自blog.csdn.net/DuanKun7323/article/details/82858729
今日推荐