Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub: How can I close the two issues with commit message?

Tags:

github

I try

git commit -m "example of coding - close #1 close #2" 
git push origin develop

but it only close #1 issue. How can I close two or more issues with commit message?

like image 547
dhooonk Avatar asked Feb 02 '20 14:02

dhooonk


People also ask

How do you close a Issues in GitHub with 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.

How do I automatically close an issue in GitHub?

All you have to do is include the special keyword syntax (eg. " fixes #5 ") in the body of your Pull Request. the referenced issue will automatically be closed when the PR is merged into the default branch. It even works across repositories.

How do I resolve a commit message in git?

On the command line, navigate to the repository that contains the commit you want to amend. Type git commit --amend and press Enter. In your text editor, edit the commit message, and save the commit.


3 Answers

You can use any of these keywords to close an issue via commit message:

close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved

The message MUST contain a string matching the following pattern: KEYWORD #ISSUE. For example: close #1.

How can I close two or more issues with commit message?

You can use comma separated list in the commit message for it.

See this link for more information.

It is also possible to close several issues in the same commit: just repeat several time the pattern to close issues. For example, the following commit message: add new quick sort algorithm, fixes #4, resolve #6, closed #12 would close, the issues 4, 6 & 12 of the project on which the commit would occur.

You can try:

git commit -m "closes #1, closes #2, closes #3; YOUR COMMIT MESSAGE"

EDIT:

Adding a link from docs.github.com.

You can link a pull request to an issue by using a supported keyword in the pull request's description or in a commit message (please note that the pull request must be on the default branch).

close, closes, closed, fix, fixes, fixed, resolve, resolves resolved

enter image description here

like image 199
abhiarora Avatar answered Oct 09 '22 09:10

abhiarora


git commit -m "Closes #1, closes #2, closes #3; rest of commit message."
like image 20
nitnjain Avatar answered Oct 09 '22 10:10

nitnjain


Please see the article closing-multiple-issues from github.

To close multiple issues, preface each issue reference with one of the above keywords. You must use the keyword before each issue you reference for the keyword to work.

For example, This closes #34, closes #23, and closes example_user/example_repo#42 would close issues #34 and #23 in the same repository, and issue #42 in the "example_user/example_repo" repository.

An example is:

git commit -m "closes #1, closes #2, closes #3; remaining commit message"
like image 4
Menelaos Avatar answered Oct 09 '22 09:10

Menelaos