GitLab contributor basics: clone, MR, conflicts
Everything else in GitLab builds on a short loop: get the code, change it on a branch, open a merge request, get it reviewed and merged. This page covers that loop for a contributor who already knows basic Git: cloning a project over SSH or HTTPS, pushing a branch and opening a merge request (from the UI or straight from git push), and resolving the merge conflicts that eventually appear.
The examples use an invented OrdersPortal project at gitlab.example.test/orders/orders-portal. UI paths and options were checked against the GitLab documentation source for GitLab 19.x in November 2026 (labels move between releases, so look for the same words if your instance is older). The conflict example was run with Git 2.43 against a local bare repository standing in for GitLab.
Topics on this page
Section titled “Topics on this page”| Topic | Use it when |
|---|---|
| Clone a repository | You need a local copy of a project. |
| Create a merge request | Your branch is ready for review. |
| Resolve merge conflicts | GitLab says the merge request cannot be merged because of conflicts. |
Clone a repository
Section titled “Clone a repository”On the project’s overview page, select Code in the upper-right corner and copy either Clone with SSH or Clone with HTTPS. The same menu can open the project directly in VS Code, IntelliJ IDEA or Xcode.
SSH is the most convenient for daily work: you authenticate with a key pair instead of typing credentials. Generate an ED25519 key (the type GitLab prefers), add the public key under your avatar > Edit profile > Access > SSH keys, then test the connection. GitLab rejects keys known to be compromised, and keys can have an expiration date and a usage type (authentication, signing or both).
ssh-keygen -t ed25519 -C "ada@example.test"cat ~/.ssh/id_ed25519.pub # paste this into GitLab > SSH keysssh -T git@gitlab.example.test # expect a "Welcome to GitLab" greetinggit clone git@gitlab.example.test:orders/orders-portal.gitHTTPS works through most firewalls and proxies. With two-factor authentication enabled (the normal case), you cannot use your password: use a personal, project or group access token with read_repository (or write_repository to push), or an OAuth credential helper such as Git Credential Manager. Deploy tokens give read-only access for automation.
git clone https://gitlab.example.test/orders/orders-portal.git# Username: your GitLab username, Password: a personal access tokenFor very large repositories, a partial clone downloads history but fetches file contents on demand: git clone --filter=blob:none <url>.
Pitfalls:
- Do not put tokens in the URL.
https://user:token@host/...works but stores the token in.git/configand shell history; use a credential helper instead. - Verify the host key once. The first SSH connection asks you to trust the server’s fingerprint; compare it with the fingerprints GitLab publishes for GitLab.com or your instance’s help page.
Create a merge request
Section titled “Create a merge request”A merge request (MR) proposes merging a source branch into a target branch and is where review, CI results, approvals and discussion come together. Each branch can have only one open merge request. The usual path is to push a branch and use the link GitLab prints, or go to Code > Merge requests > New merge request, pick source and target branches, and select Compare branches and continue. You can also create a branch and MR directly from an issue.
In the form, write a title that says what changes, describe why and how to test it (your project may prefill this from a description template), assign yourself, and request reviewers. Start the title with Draft: while the work is not ready, so it cannot be merged by accident. Mention issues with a closing pattern such as Closes #123 to close them automatically when the MR merges into the default branch.
Push options create and configure the merge request from the command line in one step:
git switch -c feature/ORD-123-free-shippinggit commit -am "ORD-123: lower free shipping threshold"git push -u origin feature/ORD-123-free-shipping \ -o merge_request.create \ -o merge_request.target=main \ -o merge_request.title="ORD-123: Lower free shipping threshold" \ -o merge_request.label="checkout" \ -o merge_request.remove_source_branch \ -o merge_request.draftOther useful options include merge_request.auto_merge (merge when the pipeline succeeds), merge_request.squash, merge_request.assign="<user>" and merge_request.description="...". ci.skip skips the branch pipeline for that push.
Pitfalls:
- Keep the branch current before review ends. If the target branch moves, rebase or merge it into your branch (or use the Rebase button when the project uses fast-forward merges) and let the pipeline run again.
- One concern per merge request. Small MRs are reviewed faster and more carefully; split refactors from features.
- Auto-merge waits for everything. It merges only when the pipeline passes and all required approvals and checks are met; unresolved threads may also block it, depending on project settings.
Resolve merge conflicts
Section titled “Resolve merge conflicts”A conflict means the source and target branches changed the same lines differently, and GitLab cannot decide which version to keep. To fix it you create a merge commit (or rebase) on the source branch that contains the resolution; GitLab never resolves conflicts by writing to the target branch.
In the GitLab UI, the merge request shows Resolve conflicts when every conflicting file is a non-binary UTF-8 text file under 200 KB (with markers), exists under the same path in both branches and contains no existing conflict markers. Interactive mode lets you pick “ours” or “theirs” per conflict; the inline editor lets you edit the result by hand for conflicts that need both changes blended. Committing creates a merge commit on the source branch. On Premium and Ultimate with the GitLab Duo Agent Platform, GitLab Duo can also resolve UI-eligible conflicts and push a resolution commit (generally available since GitLab 19.3).
On the command line, merge (or rebase onto) the latest target branch, fix the files, and push:
git fetch origingit switch feature/ORD-123-free-shippinggit merge origin/maincat config.ymlOutput:
Auto-merging config.ymlCONFLICT (content): Merge conflict in config.ymlAutomatic merge failed; fix conflicts and then commit the result.currency: EUR<<<<<<< HEADfree_shipping_over: 40=======free_shipping_over: 60>>>>>>> origin/mainBetween <<<<<<< HEAD and ======= is your branch’s version; between ======= and >>>>>>> is the target’s. Agree the right value with the other author (here, 45), remove all three marker lines, then:
git add config.ymlgit commit --no-editgit pushgit log --oneline --graph -4Output:
* f52cd31 Merge remote-tracking branch 'origin/main' into feature/ORD-123-free-shipping|\| * 6a23fff ORD-130: raise threshold for peak season* | fdb6384 ORD-123: lower free shipping threshold|/* 1684ed5 Add checkout configIf you rebase instead (git rebase origin/main), resolve each conflicting commit, run git rebase --continue, and push with git push --force-with-lease. See Merge, rebase and cherry-pick for when to choose which.
Pitfalls:
- Resolve with the other author, not alone. A conflict is two intentional changes; picking one side silently discards the other’s work.
- Run the tests after resolving. A resolution can be syntactically clean and still wrong; let the pipeline run before merging.
- Leftover markers break builds. Search for
<<<<<<<before committing; GitLab refuses UI resolution when markers are already present.
Choosing between them
Section titled “Choosing between them”| Situation | Approach |
|---|---|
| Daily work from your own machine | Clone over SSH |
| Locked-down network or a CI job | HTTPS with a token or credential helper |
| Open an MR without leaving the terminal | git push -o merge_request.create |
| Simple conflict in a small text file | Resolve in the GitLab UI |
| Many files, binary files or logic to combine | Resolve locally, run tests, push |
Interview questions
Section titled “Interview questions”Why can’t you clone over HTTPS with your password on most GitLab instances? With two-factor authentication enabled, password authentication for Git over HTTPS is not possible. You use an access token with the repository scopes (or an OAuth credential helper), which is also revocable and can be limited in scope and lifetime.
What does Closes #123 in a merge request description do?
It is a closing pattern: when the MR is merged into the default branch, issue 123 is closed automatically and linked to the MR.
Where is a conflict resolution committed, and why? On the source branch, as a merge commit (or rewritten commits after a rebase). The target branch only changes when the MR is merged, so the resolution is reviewed and tested by the pipeline like any other change.
Senior scenario: a long-running merge request conflicts with main every day and reviewers keep re-reviewing the same code. What do you change?
Split it into smaller merge requests that can merge independently, hiding unfinished behavior behind a feature flag. Until then, update the branch once a day at a fixed time, prefer rebasing so the diff stays readable, and consider merge trains or auto-merge so approved work lands before the next conflict. Settings that reset approvals on new commits should stay on, which is another reason to keep MRs small.
Related pages
Section titled “Related pages”- GitLab start page: the full learning path.
- Protected branches, approvals and code owners: what the target branch requires before your MR can merge.
- Push rules and server hooks: why a push can be rejected.
- Merge, rebase and cherry-pick
- GitLab Merge Train