3

I have main as default branch and dev as non-default.

I created one issue and one PR to merge from new temp branch to dev branch In PR, I have mentioned Resolves #1.

When I merge PR to dev branch, the issue #1 does not gets closed as it is non-default branch.

Then I using git commandline inside main branch, I did git merge dev so dev branch is merged to main.

In main branch commits, I can see the Merge pull request ... commit as well.

But the issue #1 does not gets closed even as PR is indirectly merged to main (from temp to dev to main)

Any reasons for the bug ?

Update: - When merging dev to main , next time I did not used git merge dev on main branch, but I created new PR to merge dev to main.

And it closes the issue.

Why I worked while merging with PR and not when git merge is used ?

5
  • Where did you write the Resolves #1? In the description? Commit message? Comment?
    – dan1st
    Commented May 8, 2021 at 15:50
  • In PR template...
    – Yusuf
    Commented May 8, 2021 at 20:47
  • 1
    I'm not sure why this is tagged with git when it's exclusively a github thing...
    – torek
    Commented May 9, 2021 at 7:29
  • 1
    @torek. Agree, the tag git isn't needed and only confusing
    – Julian
    Commented May 9, 2021 at 8:48
  • I'm having a similar issue with a workaround to this, where I manually link the issues to be closed. Asked about it here: github.community/t/…
    – PEZ
    Commented Feb 21, 2022 at 16:14

1 Answer 1

11

Unfortunately this is by design and not a bug

When you merge a linked pull request into the default branch of a repository, its linked issue is automatically closed

And

Note: The special keywords in a pull request description are interpreted when the pull request targets the repository's default branch. However, if the PR's base is any other branch, then these keywords are ignored, no links are created and merging the PR has no effect on the issues. If you want to link a pull request to an issue using a keyword, the PR must be on the default branch.

From https://docs.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue

PS: I have emailed GitHub support also for this in the past. Unfortunately is hasn't changed (yet)

5
  • I got your point & understood the issue. But what should I do in such cases, manually mark the issues as closed ? Also if yes, there would be no use using automated kanban with reviews as project template and normal manual kanban would work ???
    – Yusuf
    Commented May 8, 2021 at 20:46
  • 1
    You could add the Resolves #xxx to the commit description.
    – dan1st
    Commented May 8, 2021 at 20:48
  • I used to add Resolves #xxx in pull requests of features but it seems I have to add that in pull request of merging dev to prod ... correct ?
    – Yusuf
    Commented May 10, 2021 at 10:46
  • 2
    I feel so silly that I missed this. Thank you for this answer, I can sleep easily tonight.
    – Robotnicka
    Commented Aug 12, 2021 at 16:19
  • 2
    Such a pity, especially if you use a pretty common practice, where you merge feature branches into a dev branch which is then later merged into the main (default) branch.
    – Splines
    Commented Jun 7, 2023 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.