BigW Consortium Gitlab

revert_changes.md 1.87 KB
Newer Older
1 2
# Reverting changes

3 4 5 6 7 8
_**Note:** This feature was [introduced][ce-1990] in GitLab 8.5._

---

GitLab implements Git's powerful feature to [revert any commit][git-revert]
with introducing a **Revert** button in Merge Requests and commit details.
9 10 11

## Reverting a Merge Request

12 13 14 15 16 17
_**Note:** The **Revert** button will only be available for Merge Requests
created since GitLab 8.5. However, you can still revert a Merge Request
by reverting the merge commit from the list of Commits page._

After the Merge Request has been merged, a **Revert** button will be available
to revert the changes introduced by that Merge Request:
18

19
![Revert Merge Request](img/revert_changes_mr.png)
20

21
---
22

23 24
You can revert the changes directly into the selected branch or you can opt to
create a new Merge Request with the revert changes:
25

26
![Revert Merge Request modal](img/revert_changes_mr_modal.png)
27

28 29 30 31
---

After the Merge Request has been reverted, the **Revert** button will not be
available anymore.
32 33 34

## Reverting a Commit

35
You can revert a Commit from the Commit details page:
36

37
![Revert commit](img/revert_changes_commit.png)
38

39 40 41 42 43
---

Similar to reverting a Merge Request, you can opt to revert the changes
directly into the target branch or create a new Merge Request to revert the
changes:
44

45
![Revert commit modal](img/revert_changes_commit_modal.png)
46

47
---
48

49 50
After the Commit has been reverted, the **Revert** button will not be available
anymore.
51

52 53 54 55 56 57 58 59 60
Please note that when reverting merge commits, the mainline will always be the
first parent. If you want to use a different mainline then you need to do that
from the command line.

Here is a quick example to revert a merge commit using the second parent as the
mainline:

```bash
git revert -m 2 7a39eb0
61
```
62 63 64

[ce-1990]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/1990 "Revert button Merge Request"
[git-revert]: https://git-scm.com/docs/git-revert "Git revert documentation"