应用场景,多人合作开发项目的时候,我们要给别人的文件添加内容时候,首先要拉取别人的分支,下面是具体步骤

 

Administrator@AFOIH-1122 MINGW64 /d/api (master)

$ git remote -v
origin  git@github.com:test/apis.git (fetch)
origin  git@github.com:test/apis.git (push)

Administrator@AFOIH-1122 MINGW64 /d/api (master)
$ git remote add upstream https://github.com/other/apis.git

Administrator@AFOIH-1122 MINGW64 /d/api (master)
$ git remote -v
origin  git@github.com:test/apis.git (fetch)
origin  git@github.com:test/apis.git (push)
upstream        https://github.com/other/apis.git (fetch)
upstream        https://github.com/other/apis.git (push)

Administrator@AFOIH-1122 MINGW64 /d/api (master)
$ git fetch upstream
remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 1 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), done.
From https://github.com/other/apis
 * [new branch]      master     -> upstream/master

Administrator@AFOIH-1122 MINGW64 /d/api (master)
$ git checkout master
Already on 'master'
Your branch is up-to-date with 'origin/master'.

Administrator@AFOIH-1122 MINGW64 /d/api (master)
$ git merge upstream/master
Updating 177e46d..4c9fd1a
Fast-forward

1.查看分支状况 git remote -v

2. remote其他人的项目 git remote add upstream https://github.com/other/apis.git

3.再次查看分支状况 git remote -v

4.fetch 分支 upstream

5.checkout一下  git checkout master

6.merge到主分支 git merge upstream/master

总结:因为是主分支 当下一次在拉取别人的项目只需要操作 1 4  6

Comments are closed.

Post Navigation