1、确定是否建立了主项目的远程源: git remove -v
如果只显示自己的两个源(fetch, push)如下:
则说明没有建立远程的repo源。
2、需要添加主repo的源:git remote add upstream URL(URL就是主项目的地址)
3.添加完之后再次使用git remote -v 来确认。
这样就是已经创建了主repo的远程源。
4.拉取主repo源代码: git fetch upstream
5.合并主repo代码到本地代码: git merge upstream /master
注:
其中操作可能会出现Authentication failed for 的错误
解决方法是
输入:git config --list
git config --global user.name [username]
git config --global user.email [email]
如果还是在push试报错fatal: Authentication failed for
那么:输入git config --system --unset credential.helper