Work the GitLab way — feature branches, merge requests for code review, push options that save browser trips, the glab CLI, and keeping your branch up to date.
Why: on a team, nobody pushes straight to main. You branch, push the branch, and open a merge request (MR) — GitLab's home for code review: the diff, the discussion, the pipeline result, and the Merge button all live there. This workflow is the heart of using GitLab daily.
1. Branch off main
git switch -c feature/login-form2. Commit as usual
git add .git commit -m "Add login form"3. Push the branch — GitLab replies with a ready-made MR link
git push -u origin feature/login-form4. Open the printed link (or Code → Merge requests → New merge request), write a description, pick a reviewer, and create it
Why: GitLab listens for -o flags on git push — you can create the MR, set its target branch, mark it a draft, even merge it automatically when the pipeline passes, all without opening the browser.
Create an MR while pushing
git push -u origin feature/login-form \
-o merge_request.create \
-o merge_request.target=main \
-o merge_request.title="Add login form"Mark it a draft — visible, but not ready for review yet
git push -o merge_request.create -o merge_request.draftMerge automatically once the pipeline succeeds
git push -o merge_request.merge_when_pipeline_succeedsWhy: glab is GitLab's official command-line app — authenticate once and manage merge requests, issues, and pipelines without leaving the terminal. Note: install from https://gitlab.com/gitlab-org/cli — (brew install glab) on macOS, (winget install glab.glab) on Windows.
Authenticate once — pick gitlab.com and follow the prompts
glab auth loginCreate an MR from the current branch, interactively
glab mr createList open MRs / check one out locally to review it
glab mr listglab mr checkout 7Approve and merge from the terminal
glab mr approve 7glab mr merge 7Why: main keeps moving while you work. Rebasing replays your commits on top of the latest main, so your MR shows a clean diff and merges without surprises. Note: a rebased branch needs a force push — --force-with-lease refuses to overwrite work someone else pushed meanwhile, unlike plain --force.
Bring the latest main down and replay your work on top of it
git fetch origingit rebase origin/mainIf Git stops on a conflict: fix the files, then
git add .git rebase --continueUpdate the MR — safe force push only
git push --force-with-lease