Update merge_requests.md with a simpler way to check out a merge request
The previous way was put under the "By modifying `.git/config` for a given repository" section. The disadvantage is that one has to modify `.git/config` for each repository that one uses. The new way was put under the "By adding a git alias" section. One has to create this git alias once, and then it will work from any repository, without having to modify `.git/config` over and over again.
This commit is contained in:
parent
f41098adef
commit
eff3c35410
1 changed files with 15 additions and 0 deletions
|
@ -15,6 +15,21 @@ Please note that you need to have builds configured to enable this feature.
|
||||||
|
|
||||||
## Checkout merge requests locally
|
## Checkout merge requests locally
|
||||||
|
|
||||||
|
### By adding a git alias
|
||||||
|
|
||||||
|
Add the following alias to your `~/.gitconfig`:
|
||||||
|
```
|
||||||
|
[alias]
|
||||||
|
mr = !sh -c 'git fetch origin merge-requests/$1/head:mr-$1 && git checkout mr-$1' -
|
||||||
|
```
|
||||||
|
Now you can check out a particular merge request from any repository (it will use the `origin` remote) by:
|
||||||
|
```
|
||||||
|
$ git mr 5
|
||||||
|
```
|
||||||
|
This will fetch the merge request into a local `mr-5` branch and check it out.
|
||||||
|
|
||||||
|
### By modifying `.git/config` for a given repository
|
||||||
|
|
||||||
Locate the section for your GitLab remote in the `.git/config` file. It looks like this:
|
Locate the section for your GitLab remote in the `.git/config` file. It looks like this:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue