gitlab合并分支后需要提交吗_来自命令行的远程分支的存储库中的Gitlab合并请求不创建任何合并提交...

I am trying to merge a merge request (Gitlab) from command line.

After working on a dummy repository, I came to know that if I have the permission to merge a merge request, I can merge them directly through command line.

I started by cloning the upstream repository in my local system. After that, I made a change in my forked repository and created a merge request for the same.

While manually trying to merge the request from command line using this approach, I am getting an extra commit which is a merge commit(--no-ff).

git fetch

git checkout -b FETCH_HEAD

git fetch origin

git checkout origin/master

git merge --no-ff -

git push origin master

Note: The above commands are used from the cloned upstream repository.

Now, I want to do the same without cloning the upstream repository and rather by just adding an upstream remote to my forked repository.

I followed all the steps mentioned in gitlab docs for merging the request manually, but to my surprise, I am unable to see any merge commit, although the merge request is merged after using those commands.

git remote add central

git fetch origin master

git checkout -b my_master FETCH_HEAD

git fetch central

git checkout central/master

git merge --no-ff my_master-master

git push central master

So, is there any way to merge a merge request by configuring a remote in forked repository(I have permission), and generate a merge commit as well?

I tried this way as well.

git fetch central

git checkout central/master

git merge --no-ff origin/master

git push central master

I have also tried commit amend, rebase.

解决方案

I have found the solution from torek's comment above. Actually by doing

git checkout central/master

I am going to a detached HEAD, all commits in this mode are lost when I exit the node.

So the best solution should be to create a local branch which can track that upstream remote named central/master.(Please ignore my branch name)

git checkout -b centralMaster central/master

Now after doing all the above steps, we can easily solve this issue, and a no fast forward merge commit as well.

git checkout -b centralMaster central/master

git fetch central

git fetch origin

git merge origin/falcondev --no-ff -m ""

git push central centralMaster:master

Now all the above problems can be easily solved.

Please comment if I had made any mistake on these steps.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值