github操作指南-更新fork的代码

1、查看远程仓库

git remote -v

  origin https://github.com/********/l********e.git (fetch)

  origin https://github.com/********/l********e.git (push)

2、添加上游仓库

git remote add upstream https://github.com/********/l********e

3、确认添加结果

git remote -v

  origin https://github.com/********/l********e.git (fetch)

  origin https://github.com/********/l********e.git (push)
  upstream https://github.com/********/l********e (fetch)
  upstream https://github.com/********/l********e (push)

4、拉取上游变动

git fetch upstream

5、切换分支到master分支(可以不执行)

git checkout master

6、合并上游变动到master分支    也可以使用rebase命令

git merge upstream/master          git rebase upstream/master

7、推送更新到fork分支

git push origin master

查看本地git状态,可以查看有哪些文件未添加到仓库

git status

原文地址:https://www.cnblogs.com/xiaojwang/p/13532576.html