来自命令行的远程分支叉存储库的Gitlab合并请求未创建任何合并提交 [英] Gitlab merge request from forked repository remote through command line not creating any merge commits

查看:307
本文介绍了来自命令行的远程分支叉存储库的Gitlab合并请求未创建任何合并提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从命令行合并合并请求(Gitlab).

在处理完一个虚拟存储库后,我知道如果我有权限合并合并请求,我可以通过命令行直接合并. /p>

我首先克隆了本地系统中的上游存储库.之后,我在我的分支存储库中进行了更改,并为此创建了合并请求.

当使用这种方法手动尝试从命令行合并请求时,我得到了一个额外的提交,它是一个合并提交(-no-ff).

 git fetch <Fork_Repo_URL> <Fork_Repo_Branch>
git checkout -b <Branch_Name> FETCH_HEAD

git fetch origin
git checkout origin/master
git merge --no-ff <Remote_Name>-<Branch_Name>

git push origin master   
 

注意:以上命令是从克隆的上游存储库中使用的.

现在,我想执行以下操作而不克隆上游存储库,而是仅向我的派生存储库添加上游远程计算机.

我遵循了gitlab文档中提到的所有手动合并请求的步骤,但是令我惊讶的是,尽管合并请求是在使用这些命令后合并的,但是我看不到任何合并提交.

 git remote add central <Central_Repo_URL>

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
 

那么,有什么方法可以通过在派生的存储库中配置一个远程(我有权限)来合并合并请求,并生成合并提交吗?

我也尝试过这种方式.

 git fetch central
git checkout central/master
git merge --no-ff origin/master

git push central master
 

我也尝试过提交修改,重新设置.

解决方案

我从上面torek的评论中找到了解决方案.实际上是通过

 git checkout central/master
 

我要进入分离的HEAD ,退出节点后,此模式下的所有提交都会丢失.

所以最好的解决方案应该是创建一个本地分支,该分支可以跟踪名为 central/master 的上游远程服务器.(请忽略我的分支名称)

 git checkout -b centralMaster central/master
 

现在,完成上述所有步骤之后,我们可以轻松解决此问题,并且也无需进行快速前向合并提交.

 git checkout -b centralMaster central/master
git fetch central
 

 git fetch origin
git merge origin/falcondev --no-ff -m "<Message>"
git push central centralMaster:master
 

现在上述所有问题都可以轻松解决.

如果我在这些步骤上有任何错误,请发表评论.

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 <Fork_Repo_URL> <Fork_Repo_Branch>
git checkout -b <Branch_Name> FETCH_HEAD

git fetch origin
git checkout origin/master
git merge --no-ff <Remote_Name>-<Branch_Name>

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 <Central_Repo_URL>

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 "<Message>"
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.

这篇关于来自命令行的远程分支叉存储库的Gitlab合并请求未创建任何合并提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆