So in Git you can squash multiple commits into a single commit. So for example, let's say I checked in a change, but I realized I forgot something small, so I make the change locally and then I commit again. With Git squash you can merge those into one commit.
My question is does TFS have any sort of method for doing the same thing?
No. TFVC uses a totally different version control paradigm than Git; it does not support history rewriting actions like squashing and amending.
No, its not supported. You can't change the history of every changest in TFVC. If it can be achieved , it's a violation of the principle of source control.
And also you can't create a new changest then merge with the old changest, There have been a featured request in Uservoice and be declined by PM of TFS.
TFS to merge multiple, non-continuous changesets.
Thanks for the feedback on this idea. We have reviewed this feedback
and determined that we will not be able to complete this suggestion in
the foreseeable future.
Matt Mitrik TFS Program Manager
Related
My team's policy is to not check in broken code into TFS. But what if two team members are working on the same file and each member's work represents a partial solution ? One members changes won't work without the other.
How is the best way to combine the code and still follow policy of not checking in broken code ?
Both developers could create a shelveset of their changes once their own coding is complete. Once it's time to merge their code, you have 1 developer unshelve the other developer's shelveset into their own workspace. Doing this will also trigger the Merge Tool in case there are any merge conflicts that can't be automatically resolved. This should allow the developer to combine work with the other without checking in broken code.
Note that both developers should make a shevleset of their own work before unshelving the other's, in case the unshelve of the other developers work goes terribly wrong in the merge and they need to revert their own work to the un-merged state.
Here's some documentation on creating and unshelving shelvesets
Consider allowing broken code on branches. The team members could commit code to branches and merge those branches together before merging into master. Your primary or master branch should require a passing build before a pull request can be merged in.
Look at the feature branch model: https://learn.microsoft.com/en-us/vsts/git/concepts/git-branching-guidance. This does not depend on Git but it is convenient as branching is cheap.
Both developers work on the feature branch which is allowed to be broken. When they are finished they issue a pull request to the master branch. The merge is only allowed if all tests pass to make sure the master branch stays healthy.
I want to be able to review every check-in before the code is applied to the branch, is it possible in TFS?
I know we can add check-in policy to force code-review but this is applied before the check-in and not after.
I'm looking for a way that would not block the existing flow.
Thanks
TFS supports two source control systems that each have their own workflow based on established practices:
TFVC - This is a server based source control system that supports Code Reviews using Shelved changes prior to check-in. As #daniel Mann stated it works exactly as you described.
Git - This is a distributed source control system and uses Pull Requests to facilite reviews of Merges. Since all work is done on a separate branch, you review the proposed pulls of code from one branch to another.
It sounds like you are using TFVC so the existing Code Review model would fit your purpose.
I am looking for an alternative to branching in TFS with the goal of allowing multiple developers to continually integrate into a single changeset that is not in branch (aka a shelveset).
I know that a single user can update their own shelveset, and other users can pull that shelveset - but is it possible to allow several users to modify the same shelveset?
I understand that branching is preferred but I would still like to know if it is possible, maybe by using some sort of TFS powertool or modification.
No this is not possible. A shelveset is owned by a single user. it's also not recommended, as the shelveset is only a single snapshot of the change.
If you'd like something like this, you could consider git tf to create a local git repository which can be synced between two developers. Once they're finished one of the developers can push the change(s) back into TFS.
Moving from TFVC to Git has become easier with the release of TFS 2015u1:
Team Services | TFS 2015
In Team Foundation Server 2015 Update 1, a project administrator can add a Git repo to a team project created with Team Foundation Version Control (TFVC). You can also add a TFVC repo to a team project created with Git. This allows you to adopt a new version control system while preserving all the data in your team project.
As to ways to persuade people to move, that's a hard question. You'd first need to understand what is holding them back, explain the, what advantages Git brings, what disadvantages you see in the current setup. You will probably need to hand-hold or train them so they get comfortable with Git. Using git-tf for a while may give them more confidence to make the move.
Suppose I create an experimental branch in TFS. Now, I am finished with the branch, and I want to keep it around, but it has diverged sufficiently from the source branch that I want to make sure that no one can merge it back on accident. Is there a command in TFS to sever a branch, so that there is no merge path back?
I'm not sure if this will prevent a merge but in TFS 2010 you can turn a branch in to a folder
Check out Buck Hodges blog on the subject
As far as I know, you can set permissions on a branch.
We are having a problem with the TFS connection. Is there any way to do merges between branchs with the TFS down?
I don't think so since TFS merges items by comparing the items from the source/target branch which at least one would be on the server.
It would make no sense to do so. If your TFS is offline, you cannot know whether you would merge the newest source code state. This would be highly insecure since it leads to code missmatch.
If you want to merge some code offline, do it manually with tools like WinMerge and update it to your TFS when its online again ;)