How to check current branch head compare to default branch in GitLab - gitlab

GitHub web shows where is the selected branch compare to default branch. For example here dev is the default branch and I have selected qa branch. It shows that qa branch is 1 commit behind dev.
Does GitLab have the same kind functionality in UI.?

Sure!
Navigate to Repositories > Branches, the list of branches has an indicator (before status icon and Merge Request button)
once you hover above, it explains "N commits behind ... M commits ahead"
Clicking on Compare brings detailed diff in commits and files

Related

Draft merge request in GitLab is two commits behind--click "Mark as ready", or pull/rebase first?

I need your help to determine the correct order events I should follow before I perform a specific type of merge in GitLab. I have a "Draft" merge request which has the prefix "Draft:" in its title, but has been approved by all its required code reviewers. At this point it says,
Merge blocked: merge request must be marked as ready. It's still marked as draft.
Beneath that there is a warning:
The source branch is 2 commits behind the target branch
The Merge button is disabled. A little exclamation point icon appears next to it. And there is a "Mark as ready" button that is enabled and I could click on.
Am I free to click "Mark as ready" at this point, or should I first clone that project locally, catch it up with its parent branch, and push it back up to the remote repository before I click "Mark as ready"?
The GitLab web UI actually made this process quite easy despite the fact that by the time I got around to this, I was 10 commits behind!
All I did was click "Mark as ready", which removed the "Draft:" prefix from the merge request title. Then the UI said it was "Ready to merge" with a green checkmark icon. Beneath that, it said, "3 commits and 1 merge commit will be added to develop".
I suppose that meant that whatever commits I was behind, it took care of merging/rebasing that in the background--or maybe GitLab didn't do anything and I was covered because the code in my draft merge's branch was either mutually exclusive (i.e., didn't conflict) with the develop branch or it already up to date with the develop branch. Any explanations/clarifications by other more experienced software engineers are welcome! I believe that if there had been a conflict, GitLab would have presented me with further options before merging.
The "3 commits" left here at this point certainly had to do with the actual code pushed into this specific merge request by the developer.
I then clicked the two checkboxes, "Delete source branch" and "Squash commits" (as a preference). The subtitle now reflected that "1 commit and 1 merge commit will be added to develop (squashes 3 commits)." Finally, I simply clicked "Merge".
Done.

Gitlab: How to setup squash on merge?

I want to setup the squash on merge policy in GitLab. This gif showcases exactly what I would like to have:
Merge Strategies
I have set the GitLab merge method to "Fast-forward merge" and the squash commits policy is set to mandatory when merging.
Once merge is done, the git log of the main branch is exactly like I want it. The feature branch commits were squashed and the whole feature appears as one commit in the git log.
Here's the problem:
The squashed commit that is now the head of the main branch has the timestamp of the last commit in the feature branch. I would expect it to be the timestamp of when the fast-forward merge happened (squash). Is there a way to set it up in GitLab?
The merge timestamp is important for me since I need to know when the feature made its way into the main branch. However, I want to keep the commit history streamlined and straightforward, so the default option with an additional merge commit for every merge is something I want to avoid.

How to concat commit messages with GitLab MR squash?

I am using GitLab MR to push commits to my project.
I have a certain template in my commit message that I want to keep on my target branch (e.g. master).
for example:
[Notes]:
when pushing several commits in a single MR we get something like this:
Commit 1: [Notes]: Note1
Commit 2: Merge commit (the one I want to get rid of when squashing)
Commit 3: [Notes]: Note2
when squashing with GitLab MR the squashed commit message is the title of the MR, which prevents me to keep my original commits template.
Is there an option in GitLab setting to change the squashed message to be a concat of all commit messages? similar to interactive rebase in git.
wanted behavior:
Squashed Commit: [Notes]: Note1
Merge commit (the one I want to get rid of when squashing)
[Notes]: Note2
GitLab 14.9.2-ee
I managed to find what I was looking for, it is a GitLab feature introduced in the FREE edition since GitLab 14.6.
Open GitLab website -> Settings -> General -> Merge requests -> Squash commit message template.
Then in the textbox add the following flag:
%{all_commits}
The commit messages are shown in the squash message according to their chronological order.
I do have this checkbox (see attached image) in my merge request enabling me to change the Merge Commit Message but I am using: 15.2.1-ee I'm not sure on what version this got introduced. I think there was a similar functionality in previous versions.

Different branches shown in the same remote branch

I have a problem. I have wrongly merged the master branch in a minor branch. Now I have these two branches shown as one only branch into the gitlab repository which definitely not correct.
I need to separate these two branches as they were originally, the master branch (integration) and a test branch (playpen-jimi). Anything to suggest? thank you very much. Attached you will find a screenshot of the merged branches in the gitlab repository.
enter image description here

How to do a code review for many commits in gitlab?

What is the easiest/best way to review a merge request in gitlab for a branch that has many commits?
Is there a “unified” view I can use somehow or is the only option to click on the “Changes” tab and go through each individual commits one by one?
You do not need to go through each invidividual commit one by one.
You should click on the Merge Request's "Changes" tab, instead of the "Changes" tab of individual commits, so you see the changes between the latest version and the branch you want to merge into, e.g. with Master:
This way, you will see all changes that are proposed within the merge request and you can review them all at once.

Resources