Commit 4277123c authored by Rami Alshafi's avatar Rami Alshafi

Merge branch '2-list-create-a-merge-request-from-an-issue-before-merge-branch' into 'master'

Resolve "List create a merge request from an issue before merge branch"

Closes #2

See merge request rami/docs!4
parents 77a5b274 72811bc5
......@@ -21,28 +21,40 @@ Copy the clone path and type the following command
$ git clone (paste the clone path here)
***
## Merge Request
## Creating Merge Requests
Merge requests allow us to exchange changes made to source code and collaborate with developers in Gitlab. Additionally, merge requests serve as a code review as well. There is no need to fork the entire project although you can.
In order to submit a merge request to any project in Gitlab, do the following steps:
### create your own branch
From the root directory of your local cloned repository, type the following command
***
$ git checkout -b (name of your branch)
***
![New branch cmd](/assets/newBranch.PNG)
### commit changes
Once you make the changes, stage and commit your changes and push your local branch to the remote repository with the following command
***
$ git push -u origin (name of your branch)
***
### Create the merge request.
There are many ways to craete a merge request. For example, you can checkout your branch from the branch drop down menu in the project main page.
![checkout branch](/assets/checkoutNewBranch.PNG)
### Method 1: (Merge from pushed branch)
1. After cloning a repository, create your own local branch. From the root directory of your local cloned repository, type this command `$ git checkout -b (name of your branch)`.
![New branch cmd](/assets/newBranch.PNG)
2. Make your changes them stage and commit them on your local machine in your brnach and push it back up to the remote repository with this command `$ git push -u origin (name of your branch)`.
3. From the Gitlab UI, Browse to the branch list and find your pushed up branch.
![checkout branch](/assets/checkoutNewBranch.PNG)
4. Click the "Create merge request" blue button in the upper right corner to create the merge request. This will take you to the New Merge Request page where you can complete the merge request.
From the same page, click the "Create merge request" blue button in the upper right corner to issue the merge request.
![MR Button](/assets/MRButton.PNG)
![MR Button](/assets/MRButton.PNG)
The merge request form will open up, fill it out with the proper title and description. If you are still working on the changes, assign it to yourself and include the "WIP:" prefix in the title. Otherwise, assign it to the responsible maintainers if the changes are completely done. The source and target branches will be auto-selected but they could be changed as needed.
### Method 2: (Merge from issue)
Alternativly, you can also create a merge request from an issue which will automatically create a feature branch for it where the changes will end up along with a merge request with a pre-populated title with the `WIP:` prefix and the issue description among other fields.
1. create an issue or select already existing issues from the issues tab.
2. From the issue page select “Create merge request”. The source branch and branch name can be change by clicking the little down arrow to the right of the `Create merge` request button. If you are trying to merge with a branch other than master it must be selected at this time.
![MR From Issue](/assets/MR_creation_from_issue.PNG)
3. Make your changes in the newly created branch and iterate and review until your changes mature.
4. Remove the `WIP` prefix and select an assignee for merging it to the target branch. The description will be auto-populated with `closes #<issue number>` You can add `/cc <users you want to also review this commit>`
### Method 3: (merge from a fork)
This method is similiar to the Github workflow where you can fork a project into your own namespace and make your changes and then create a merge request where the source is a branch in your fork and the target is the branch of the main repository
## Completing merge requests
Once the merge request form opens up, fill it out with the proper title and description. If you are still working on the changes, assign it to yourself and include the "WIP:" prefix in the title. Doing so will mark the merge request as Work in Progress. Otherwise, assign it to the responsible maintainers if the changes are completely done. The source and target branches will be auto-selected but they could be changed as needed.
![MR Form](/assets/MRForm.PNG)
It is customary to squash all commits in your feature branch into one or a few logically organized commits and delete your feature branch once merged into the target branch. You can check these options now or later.
......@@ -51,8 +63,7 @@ Once done filling out the merge request form, click on the "submit merge request
The merge request will be created and the CI pipeline will be kicked off if enabled.
Alternativly, you can also create a merge request from an issue which will automatically create a feature branch for it where the changes will end up along with a merge request with a pre-populated title among other fields.
![MR From Issue](/assets/MR_creation_from_issue.PNG)
### Working with Merge Requests
Now that you have a merge request, you can share it with a teammate to get their reviews and they can provide their feedback or contribute to the merge request; the step-by-step instructions of which will show up if you click on the "checkout branch" button from withi the merge request page.
![MR checkout branch](/assets/MR_checkout_branch.PNG)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment