Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close Gitlab issue via commit

Tags:

gitlab

I spend my day doing this:

  1. Read an issue on a Gitlab-powered issue tracker,
  2. Fix the issue,
  3. Commit and push to the same Gitlab-powered Git server,
  4. Mark the issue as closed.

To remove the 4th step, how can I close the issue automatically when committing?

like image 511
Nicolas Raoul Avatar asked Jun 30 '17 05:06

Nicolas Raoul


People also ask

How do you close an issue with a commit?

To link a commit to a GitHub Issue, put the issue number with the # character in the Comment text box. For example, #111. To close a GitHub issue, put a keyword and put the issue number with the # character in the Comment text box. For example, Close #111.


2 Answers

Commit and push using this syntax:

git commit -m "Sort more efficiently" -m "Closes #843"
git push

This will commit and close the issue.
Note that unlike Github a single -m will not work.
The following will appear on the issue page:

enter image description here

References:

  • https://docs.gitlab.com/ee/user/project/issues/automatic_issue_closing.html
  • How to commit a change with both "message" and "description" from the command line?
like image 136
Nicolas Raoul Avatar answered Oct 13 '22 23:10

Nicolas Raoul


According to this link from gitlab, you will be able to do that with a variety of words such as "fixes" or "closes". It does not need to be in a seperate line.

So you could have the following message:

Fixes #20. I had to replace "foo" with "bar".

And that will close issue #20.

like image 26
thalacker Avatar answered Oct 14 '22 00:10

thalacker