In the project's warehouse, there is a project A, and I fork it into my own warehouse as project B.
At this time, the branches of project B and project A are the same. Later, after creating a new branch in project A, how do I synchronize this branch to project B?
Add:
Project A is built on gitlab, so the fork operation is also performed on gitlab
On gitlab, it seems that there is no such operation as new pull request
How to implement my above requirements in the Linux command line
迷茫2017-05-02 09:28:58
new pull request Use other people’s projects as sources and synchronize them to your project
阿神2017-05-02 09:28:58
Take github as an example. For project B after forking, use the new pull request button, and then select the subsequent list to obtain each branch on A
滿天的星座2017-05-02 09:28:58
In this case, as far as I know, there are two ways:
If it is github, you can follow the method given by Dade. I don’t know if gitlab has it. This method is more convenient.
You can follow the method you gave, first pull the update of library A to the local, then merge it locally and push it to the library B.
漂亮男人2017-05-02 09:28:58
I asked a colleague for advice today, and one method he gave is
# 1.将项目B clone 到本地
git clone -b master 项目B的git地址
# 2.将项目A的git地址,添加至本地的remote
git remote add upstream 项目A的git地址
# 3.在本地新建一个分支,该分支的名称最好与项目A中新增的那个分支的名称相同以便区分
git checkout -b 新分支名称
# 4.从项目A中将新分支的内容 pull 到本地
git pull upstream 新分支名称
# 5.将 pull 下来的分支 push 到项目B 中去
git push origin 新分支名称
Among them, the above two steps 3 and 4 can be combined into the following step:
git checkout -b 新分支名称 upstream/新分支名称
The above process, in general, is to pull the branch of project A to the local, and then push from the local to project B, that is, the local is used as an intermediate bridge.
If you have other methods, please feel free to tell me!