简体   繁体   中英

How to stage commits in TFS 2017 when doing pull request?

When 2 Developers have 5 commits in TFS, first developer(2 commits) and second developer(3 commits) on DEV branch and first developer wants to create pull request to merge his changes to TEST branch and second developer doesn't, he is forced to merge ALL changes(5) instead of his 2 changes. Is there some kind of stage like in Visual Studio when commiting? I know for cherry pick but that is too many steps and takes time. Is there any other way to make this work? We are doing pull request on Team Foundation Server 2017 (not in visual studio)

TL;DR: the 2 devs should not push in the same branch used to do the PR.

Now we have 5 commits on DEV branch. The point is that the first developer doesn't want to merge ALL changes because 3 files of 5 are not his.

A pull request is made on the ref of a branch. That means that all the commits of the branch are intended to be merged. Even also the one pushed later. Until the pull request is merged.

Why should he merge other people changes.

So why are they working in the same branch?

If you want to avoid merging all the commits in your PR, there is no miracle, the 2nd dev must create a new branch (it's very easy and quick to do it).

That branch could be created from the commit you want (either the initial one or the one of the other dev branch, as you want).

And the 2nd dev, if needed should sync it's branch doing rebase(s). (I know that rebase was impossible to do in the first version of Visual Studio supporting Git but it should not be a problem now.)

No need of cherry-picking.

Have a look at the GitHub flow (that's the same even if you don't use GitHub)

Is there some kind of stage like in Visual Studio when commiting?

No, that's called "using branches" because they are very lightweight in Git (and bring a lot of benefits)

If you want to choose the specified commits to merge when you do pull request,as far as I know, there should be no other way . Whenever we create a pull request, we merge all commits into the target branch. We can't specify which commits to merge and which do not.

As a workaround you can select the node you want to merge in the commits history to create a new branch, and then create a pull request, so that the pull request only contains the current node and the previous commits, will not include subsequent commits. If the commits of two developer are out of order. This method will be very troublesome.

在此处输入图片说明 在此处输入图片说明

In addition, you can try creating a branch for each developer to do commits and pull request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM