GitHub - PR linked issue does not gets closed when non-default branch is merged with main - github

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 ?

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)

Related

github 'resolve conflicts' button disabled

I'm an admin on this repo. In this PR I have removed multiple files and merged these changes from local to origin/develop. When merging origin/develop to origin/master I'm getting this conflict for one of the four files I've removed. Our flow is always local to origin/develop to origin/master. I had no conflicts when mergin local to origin/develop.
Github won't let me resolve the conflict.
Questions:
Why is the 'Resolve Conflicts' button disabled? I've never seen this before.
Why would this one file have a merge conflict? It's one of 3 config files that I removed completely in this PR.
Why am I getting this conflict on origin/develop to origin/master when I had no conflicts on local to origin/develop?
If the Resolve conflicts button is deactivated, your pull request's merge conflict is too complex to resolve on GitHub Enterprise or the site administrator has disabled the conflict editor for pull requests between repositories. You must resolve the merge conflict using another Git client like Atom's Git integration or the command line.
I know this is little old post. But putting my answer as I also faced the same issue and I could solve it using following.
As shown in screenshot attached, you can solve this on your local using command line.
Fetch the branch which has conflicts. (say master branch)
Checkout to that branch.
Pull the code from another branch you want to merge it into. (Take a pull from develop into master )
OR Rebase the branch as: checkout to develop branch, then take pull into it git pull origin develop. Then checkout to master branch and do git rebase develop.
Now resolve the conflicts, add the changed files, commit it, push onto the branch you want to merge it into (in this case master ). It might happen that you don't have permission to do it. In that case you can push this branch on your fork, and then raise PR to main repo)
There is one more method.
Using GitHub Desktop. Just that, it is not available for linux from official site.
For this you can check this link.
Read the instructions in the README doc and install it accordingly.
And you can find the method to solve the conflicts using GitHub Desktop here.

VSTS: Difference between default and compare branch

In my git repository I have three branches: master: default, dev: compare, and temp.
When I create a Pull Request from temp branch it defaults to dev as the target.
It is in contradiction with what Microsoft documentation says:
Change the default branch used to merge code into when your team
creates new pull requests. This is useful when you want to use a
branch other than master for the main line of development in your
repo.
Am I missing something?
For default branch, it helps you to treat the branch as default when cloning the git repo locally or creating a PR.
Such as if you treat master branch as default branch (by default), when you cloned the git repo locally, the local branch is master. And when you creating a PR, it will automatically treat master branch as the target branch.
For compare branch, it helps you to decide how many commits on the other branches are behind or ahead by comparing commits on other branches with the compare branch.
Such as for above example, develop branch is compare branch, and master branch and nn1 branch are compare with develop branch.
For comparing master branch with develop branch, there has 0 commits behind and 0 commit ahead (master branch same as develop branch). For comparing nn1 branch with develop branch, there are 3 commits behind and 48 commits ahead.
I did some quick tests in my VSTS tenant. It looks like the default branch of a new pull request is always the Compare branch, rather than the Default branch. So if you set your master branch as Compare branch, it should become to the default for new pull requests.
Not sure if it is bug of VSTS, or if they change the behavior of pull request without updating the doc.
Update:
I did some further research. It turned out that this change was introduced in a Oct 2016 feature roll out:
You can now set your compare branch to something other than the
default branch. This setting will be remembered on a per-user basis.
Pull requests and new branches created from the Branches page will be
based off the branch you set as the compare branch.
So the doc needs to be updated.

github pull request from a single branch

I have forked a master from upstream, and have created two branches from it. Is it possible to send in PR from a single branch?
I did that, and despite the github web UI is creating the PR against a single branch, I noticed the changes from the other branch is included in the PR request as well.
What's the correct way to send in PR from a single branch?
The likely problem is you didn't git checkout master before creating the second branch, then the second branch you created is descendant from the first branch you created. Just checkout to master before adding the second branch.

Checking out a github release in Eclipse egit?

How do I set egit to pull a release from github, rather than just the master?
I'm looking to checkout a release 0.4.0.
In the attached, the item checked out isn't pulled from remote - in properties the rebase, remote and upstream branch aren't set. I got this checkout from the tags, but it isn't correct.
You have already checked out the right commit: the head of your current branch v0.4.0-branch is the commit 23d3472 that is tagged as v0.4.0.
In Git a tag references a commit, not a branch. One commit can be in or even the head of multiple branches. For a release, a tag instead of a branch is usually used if the release is not intended to be maintained. Instead, contributions are welcome on top of the latest stage/commit of a specific branch (to avoid merging or rebasing), mostly on the master or on a dev(eloper) branch.
In your case, to contribute to VCVRack/Rack:
In GitHub fork the VCVRack/Rack repository (assuming you are not member of this project)
In Eclipse clone the forked GitHub repository
In Eclipse commit and push your proposed change as a single commit to the master branch of your forked GitHub repository (currently, there are 177 commits to master since the v0.4.0 tag)
In GitHub create a pull request based on this commit

How do "reuse" a branch on Bitbucket / Sourcetree after merge

I was working on a branch of my Bitbucket repo (lets call it "frontend-dev"), which has now been merged with the master branch. I would like to branch again to make further changes, without creating a new branch. How do I branch and get back onto "frontend-dev".
I am using Sourcetree to manage version control.
Normally merging to master does not close or delete the branch. If there are changes in master since the merge from "frontend-dev", you can merge back to "frontend-dev". Either way, you can then simply switch your working copy to "frontend-dev" and continue developing.
Another question discusses what to do when you have closed or deleted the branch: Restore Merged Branch in Bitbucket Repo