首先需要从主库 fork 代码到用户空间下。
http://10.166.15.223:6880/autoeval/autoeval.git
fork =》
http://10.166.15.223:6880/cliffordl/autoeval.git
拉取代码,应该拉取用户的代码吧
[user@node3 ~]$ git clone http://10.166.15.223:6880/autoeval/autoeval.git
Cloning into 'autoeval'...
Username for 'http://10.166.15.223:6880': cliffordl
Password for 'http://cliffordl@10.166.15.223:6880': password
remote: Enumerating objects: 21, done.
remote: Counting objects: 100% (21/21), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 21 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (21/21), done.
首先查看 git remote 信息
[user@node3 autoeval]$ git remote -v
origin http://10.166.15.223:6880/cliffordl/autoeval.git (fetch)
origin http://10.166.15.223:6880/cliffordl/autoeval.git (push)
添加主库 upstream。(是否需要为主库添加 upstream 并且推到远程。)
[user@node3 autoeval]$ git remote add upstream http://10.166.15.223:6880/autoeval/autoeval.git
[user@node3 autoeval]$ git remote -v
origin http://10.166.15.223:6880/cliffordl/autoeval.git (fetch)
origin http://10.166.15.223:6880/cliffordl/autoeval.git (push)
upstream http://10.166.15.223:6880/autoeval/autoeval.git (fetch)
upstream http://10.166.15.223:6880/autoeval/autoeval.git (push)
[user@node3 autoeval]$
禁止 push
[user@node3 autoeval]$ git remote set-url --push upstream no_push
[user@node3 autoeval]$
[user@node3 autoeval]$ git remote -v
origin http://10.166.15.223:6880/cliffordl/autoeval.git (fetch)
origin http://10.166.15.223:6880/cliffordl/autoeval.git (push)
upstream http://10.166.15.223:6880/autoeval/autoeval.git (fetch)
upstream no_push (push)
将远程 upstream 的代码替换到当前 master 之上。也就是以 upstream 为最新。
[user@node3 autoeval]$ git checkout -b fix-1
拉取主库 upstream 代码
[user@node3 autoeval]$ git checkout master
Switched to branch 'master'
[user@node3 autoeval]$ git fetch upstream
Username for 'http://10.166.15.223:6880': cliffordl
Password for 'http://cliffordl@10.166.15.223:6880': password
From http://10.166.15.223:6880/autoeval/autoeval
* [new branch] master -> upstream/master
将主库 upstream 代码合并到本地 master 之上
[user@node3 autoeval]$ git rebase upstream/master
Current branch master is up to date.
将本地 master 推到用户仓库(而非主库)
[user@node3 autoeval]$ git push origin master
Username for 'http://10.166.15.223:6880': cliffordl
Password for 'http://cliffordl@10.166.15.223:6880': password
Everything up-to-date
[user@node3 autoeval]$