git 配合 github 远程协作

远程操作

我使用的是 github , 如果是其他的, 可能略有不同, 如国内的 码云 coding 等..

在进行后面的操作之前, 请先注册一个 github 账号

本地仓库 <=> 远程仓库

  1. 在添加一个远程仓库 git remote add master github仓库名 仓库url

仓库的url,可以在 github 的仓库主页中的 clone or download 按钮中找到

git remote add master my-test  https://www.github/liaohui5/my-test
  1. 将本地的 master 分支 推送到远程仓库 git push -u git仓库名 master

此时会提示需要输入用户名, 然后输入密码

git push -u mytest master
  1. 第一次配置好后, 之后再提交就可以直接使用 git push 来进行提交, 但是每次提交都需要密码,

    可以根据需要配置 免密提交

git push
  1. 配置好后, 就可以使用 git pull 来获取 github仓库中的 代码和分支
git pull

其他常用远程操作

  • 查看所有的远程仓库
git remote -v
  • 删除远程仓库 git remote remove github仓库名
git remote rm my-test
原文地址:https://www.cnblogs.com/liaohui5/p/10581575.html