Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect an issue with a commit after the commit

Tags:

github

I did a git commit and pushed to github, but forgot to mention the issue number in the commit (I forgot to write something like ... closes #123).

If I had mentioned the issue number in the commit message, github would have connected the commit to the issue. Is there any way to do this after the commit, when it's too late for me to change the commit message?

EDIT: Assume that it's too late to amend the commit or otherwise alter the history. I am really asking about github functionality, not git.

like image 902
Dan Halbert Avatar asked Sep 26 '13 18:09

Dan Halbert


People also ask

How do you reference an issue in a commit?

You just need to include #xxx in your commit message to reference an issue without closing it. With the new GitHub issues 2.0, you can use these synonyms to reference an issue and close it (in your commit message).

How do I link to an issue in GitHub?

To link related issues in the same repository, you can type # followed by part of the issue title and then clicking the issue that you want to link. To communicate responsibility, you can assign issues. If you find yourself frequently typing the same comment, you can use saved replies.

What do you do after commit?

Add and commit changes These two commands make up the bulk of many workflows that use git for version control. Modified files are staged using git add, and following a commit, all files in the staging area are snapshotted and become part of the repository's history, receiving a unique SHA-1 hash identifier.


2 Answers

In your issue on GitHub, just write a comment with the commit hash. For instance:

Fixed with commit 61d949320fc0bf1a8dba09b3845bddcd153b1a64 

GitHub will recognize it as a SHA and link to the right commit page.

like image 83
Arthur Clemens Avatar answered Oct 05 '22 13:10

Arthur Clemens


The Github help page "Can I delete a commit message?" explain how to alter:

  • a commit you just pushed
  • older commits message

But since it changes the history, you need to make anyone having already pulled from the GitHub repo aware of that change.


If rewriting the history isn't possible, you can make a new commit, with a commit message including:

  • the close issue
  • the SHA1 of the previous commit.

GitHub will automatically link that old commit in your new commit message: see for istance the reference to commit cdfd948 in this git commit.

like image 28
VonC Avatar answered Oct 05 '22 13:10

VonC