Instructions to merge manually result in detached HEAD and do not push result
Instructions to merge manually are:
Step 1. Fetch and check out the branch for this merge request
git fetch origin git checkout -b <branchname> origin/<branchname>Step 2. Review the changes locally
Step 3. Merge the branch and fix any conflicts that come up
git fetch origin git checkout origin/master git merge --no-ff <branchname>Step 4. Push the result of the merge to GitLab
git push origin master
The problem is:
-
Step 3 checks out
origin/master, resulting in a detachedHEAD -
Step 3 then merges to the detached
HEAD, which does not modifymaster. -
Step 4 pushes branch
master(i.e. the localmasterto the remotemaster). It does not push the newly created merge commit on detachedHEAD.
In comparison, GitHub's instruction say:
Step 1: From your project repository, check out a new branch and test the changes.
git checkout -b <user>-<branchname> master git pull https://github.com/<repository> <branchname>Step 2: Merge the changes and update on GitHub.
git checkout master git merge --no-ff <user>-<branchname> git push origin master
The big difference is that GitLab advises git checkout origin/master (hence detached HEAD) while GitHub advises git checkout master. I suggest fixing the GitLab instruction to advise git checkout master too.