2

We use TFS 2017 (15.117.26714.0) with git. When we try to make a pull request, TFS says "Pull request cannot be automatically merged.".

I'm just trying to figure out what's happening but I didn't find any message on why the pull request cannot be automatically merged.

Do you know how to debug "Pull request cannot be automatically merged."? Is there a hidden option or a link to a log that can help me?

Update

You can find a little report about the job that is supposed to execute the merge during the pull request on a dedicated page of the web server. You can find it in http://my.tfs.server:8080/tfs/_oi or https://my.tfs.server/_oi then search for a job named Git Native MergeJob. You must have administrative rights to access it.

This provides a result message for that job which can be an exception with a callstack if the job has failed.

However, in my specific case, the job is executed successfully and the result message is Successfully tried merging. while the message from the pull request is still Pull request cannot be automatically merged.

So, I need to dig deeper and find a log (if it exists!) of that specific job. Anyone knows where I can find it?

Hemel
  • 313
  • 3
  • 13

3 Answers3

2

Git is very good at automatically merging file changes in most circumstances, most pull requests can be "automatically merged" which means there are no conflicts between it and the target branch.

However, if somebody else makes a change to one of the same files as you TFS will no longer attempt to merge your branch. If TFS could not offers suggestions on how to correct this. You may get this kind of error info "Pull request cannot be automatically merged."

You could double check this by pull down the two server branches to local and compare with each other. If there some conflicts, suggest you take a look at resolve merge conflicts.

Some similar issue for your reference:


Besides, to avoid this kind of issue, you could set up the branch policy to protect your branch. After you set up a branch policy, others cannot directly push changes to the branch. Changes to the branch are only made through pull requests.

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • I did that, trying to merge locally and there is no issue at all (only one line changed on the whole repository). No we have another issue that is not related to the merge itself. I'm guessing some .gitconfig issues. But what I want is a log about what happened. – Hemel Jan 31 '18 at 13:30
  • @Hemel Sorry about this, there is no such related log for troubleshooting in TFS web portal. Have you tried abandon the pull request and create a new one , which may do the trick. – PatrickLu-MSFT Jan 31 '18 at 13:36
  • Yes, I tried abandon the pull request and restarting it three times, always the same error message. It's too bad we cannot see what fails :'( – Hemel Jan 31 '18 at 13:39
  • @Hemel This is wired, if there are just one line changed and not have any merge conflicts between the pull request branch and the target branch. You could double confirm this in the web portal though Browse code changes (https://learn.microsoft.com/en-us/vsts/git/pull-requests#browse-code-changes ) Besides, did you mean there are something wrong in the server side .gitconfig? Seems impossible, what other situations could prove this? – PatrickLu-MSFT Jan 31 '18 at 17:10
  • Yes, maybe we have to set the `http."https://my.company.tfs".sslCAInfo` variable to point to a certificate downloaded to the disk. Without that, the source code cannot be downloaded (at least on developer machines). – Hemel Feb 01 '18 at 17:43
  • You said there is no log for troubleshooting in TFS web portal but do we have a log on the server itself? I have Remote access to the server so hopefully I can retrieve the log! – Hemel Feb 02 '18 at 13:31
  • @Hemel Sorry for the later reply due to holiday. TFS has two tables in the Tfs_Configuration and Tfs_CollectionX databases called `tbl_Command` and `tbl_Parameter`. This tables keep a record of every single command that every single user has executed against TFS for the last 14 days. You could see this in the new web-based administration interface.Details please refer https://blogs.msdn.microsoft.com/granth/2013/02/13/tfs2012-new-tools-for-tfs-administrators/. However, just as your update info mentioned, it will not expand the error info, just list the same as pull request showed. – PatrickLu-MSFT Feb 05 '18 at 15:23
  • @Hemel Besides, seems your original issue should more related account/branch / repository. Not the .gitconfig file. To narrow down the issue, you could use another account to create a pull request. Use another branch, repository to store the source and do the pull request. – PatrickLu-MSFT Feb 05 '18 at 15:23
  • Thanks for your answers ! I finally tested with many other accounts, and it seems that my account is the only one that cannot merge the branches during a Pull Request... – Hemel Feb 06 '18 at 10:33
0

Means you don't have the latest master.

You're supposed to pull the latest master, merge it into your feature branch fixing all conflicts, then do your pull request.

Sacha K
  • 602
  • 6
  • 22
  • This is what I did. I suppose we have a configuration issue somewhere. I just want the logs to be sure of that. – Hemel Jan 31 '18 at 13:27
  • I don’t think that there is something to configure there. Git files are stored in the SQL database of TFS, so I don’t think you can go open a git command line on the server either. I’d push the 2 branches somewhere else and see what happens when doing a pull request. – Sacha K Jan 31 '18 at 15:54
  • Actually, in my company, we have a little SSL issue with git that prevents to download the code from TFS. This can be easily fixed by changing the .gitconfig file. I do think there is exactly the same issue on the TFS server itself when it tries to merge the branches. I just wanted to be sure of that before trying to change the server-side .gitconfig. Anyway, I'll try to reproduce this pull request on another TFS server with the same repository. – Hemel Jan 31 '18 at 16:35
0

You can find a little report about the job that is supposed to execute the merge during the pull request on a dedicated page of the web server. You can find it in http://my.tfs.server:8080/tfs/_oi or https://my.tfs.server/_oi then search for a job named Git Native MergeJob. You must have administrative rights to access it.

Depending on what the issue is, you may have the exception and a callstack that can help understand why "Pull request cannot be automatically merged".

Most of the time, you'll find that a file is "too big" to be handled by TFS, see this issue on github.

Hemel
  • 313
  • 3
  • 13