Restrict to commit file in checked-out state in TFS - visual-studio-2013

I have two branches say dev and rel. If I am changing file 'A' under dev and without commiting I will mergr to rel, I am getting change status as "[merge]". And If change the file, commit it in dev and then merge to rel status will be "[merge,edit]".
Is there is any option in VS 2013 where it should not allow to merge the file for developers if it is in checked-out state.
Scenario:
One file already committed to the server with change and second file is in checked out mode and not checked-in to the server.
So first file merged separately which got merged and then after changing the second file, added first and second file in single change set with checked out mode of second file. So no conflicts while merging because second file code was in checked out mode..
How to go ahead where - Developer cannot merge if file is in edit mode.. it should allow only when changes are checked in to server.

No this isn't possible. The ability to edit files during merge is required in order to be able to perform conflict resolution.

In TFS, merge specifically means that its this revision contains the merge from a another branch. however,merge only represent the merge operation. So it shows [merge] status for the unchanged file and shows [merge,edit] status for the files that actually changed and shows [merge branch] for the new add item.
It's not possible to restrict users to do the merge files when the files be checked out. This is used to resolve the conflicts.
We do not have this kind of build-in feature for local workspace. If you are using server workspace, you could try to sue Check-out lock for target branch, a check-out lock prevents users who are using server workspaces from checking out and making changes to the locked item in their workspaces. You cannot apply a check-out lock to an item for which any pending changes exist, in any workspace other than your own. More details take a look at this link.

Related

TFS - How to carry on working on file which has pending check in changes?

I have shelved my changes in TFS which will be checked in few days time. Now i want to work on different TFS card which belongs to same file. How can i work on the same file when its changes are not checked in yet ?
How can i work on the same file when its changes are not checked in yet ?
You should use Branch. You can create a new branch based on file are not checked in, then you work on different TFS card with previous branch, after that, you can check out the new branch to work on the same file when its changes are not checked in.
Shelvesets are per-user and differently stored in the source control - it is not possible to merge shelvesets, there's no history etc. The only action possible is unshelving; you cannot even merge files while doing so. So, we only use it as a temporary storage for things that are not finished yet and thus cannot be checked into a branch.
So, you should use branches. Maybe a Main branch and different development branches for features & bug fix.
Hope this helps.

Within Team Explorer, is there a way to persist changes without merging them?

I work on a project that has a series of configuration files. From time to time, these files need to be updated with new properties or settings, or we update how content is stored in some of these fields. This means that we need to update these files to our project source control since we need to push these changes to all of the devs on this project, when these changes occur.
However, 95% of the time we want to ignore the changes in our local configs because they contain data-specific changes that are specific to a particular developer or his machine.
What I'd like to do within TFS is choose whether to commit the changes in these configuration files, or not, with each upload. Preferably, I'd never commit my personal changes (as they relate to my personal, localized data.) However, if I unstage this work, I can't switch branches until the changes are committed. If I undo the work, it's quite a pain to switch branches and then manually recreate all of those personal changes.
Is there away in TFS to store a set of changes, and when I update or switch my local branch, re-apply the changes to my local working set? Also, I don't need TFS to ignore these file-changes. Sometimes I do need to upload changes, especially when we're adding new config keys or changing the structure of the data. In such a case, I push up my file and everyone else will see the change in structure. However, if we can all apply localized patches to the specific regions/portions of the files with our user-specific code, it will save us a lot of time in re-integrating these files into our local, working projects. Can this be done?
According to your description, you could use shelvesets to handle the situation.
Since some of the pending changes that are not ready for check in, you could suspend your work and work on a different task/branch.
You can move your pending changes to a shelveset on the server and then clean your workspace. The shelveset saves and stores not only your file revisions, but also the Comment, the list of Related Work Items, and check-in notes (if you evaluate policies before shelving).
After the work have done, you could resume the shelveset to pending changes, unsheveset to local and keep working on it.
You could do this either from VS IDE or tf command line, more details please refer this tutorial: Suspend your work and manage your shelvesets

What will happen if someone modifies & checks in a shelved file?

What will happen if Developer A checks out a shelved file, make some changes and check it back in.
Meanwhile, Developer 'B' is looking at the shelved set and he decides to work on the same file which is now updated & checked-in by Developer 'A'.
Will TFS pull up the Merge change screen or will it allow Developer B to access the originally shelved file?
It depends on the workspace version of developer B. If developer B is on the version from which the shelf-set was created, he'll be able to work in the file with no interruptions.
If he's on a newer version and when there have been changes to the file since the shelf-set was created, he'll be asked to merge.
If he's on the version after A checks in the changes to the shelved file, he'll likely be prompted to merge the changes, or when the changes are in tune with the workspace, will just be able to unshelve the changes without being pompted.
In general it's better when two developers don't work on the same shelveset, in such case it's better to create a temporary branch (topic branch/feature branch).

TFS Merge Deadlock

I am attempting to perform a merge in TFS. After completing the Merge Wizard I received conflicts with most of my files. They were all “Existing File” conflicts with the error below
“a non version controlled file or writable file by the same name already exists locally”
I chose to overwrite all local files. When I open the target solution all of the changes I am attempting to merge are not there and I receive build errors. However, when I select “Check-In” - I can see them under Included Changes as [merge, edit] or [merge,branch]. It’s like they’re in some indeterminate state.
I’m not exactly sure how to get pass this. I tried to check-in the changes and I receive an error telling me to “Get Latest.” When I try “Get Latest” – I receive the message “Unable to perform the get operation because the file already exists locally”
Any ideas on how to get past this deadlock?
The target branch which in your local work space compare with the one in source control explorer must be some conflicts.
A simple way to solve it. You can delete your local mapped target branch(copy a backup to a different folder ).Then get latest version of the target branch from source control. Do the merge again, check in the pending changes.

TFS Conflict Type: Writable File - A writable file by same name exists locally

I'm trying to get latest of my project. When I do, TFS shows me that I have conflicts on every single file in that project. Every file has the same conflict: Conflict Type: Writable File - A writable file by same name exists locally.
The resolution it gives me is "Overwrite Local File or Folder" but I have to do this one by one.
Why does TFS thinks that I have conflicts (I haven't changed any files)?
The Visual Studio 2010 conflict resolution dialog supports multi-select.
If you select the first conflict, hold down Shift then select the last conflict, the "Overwrite Local File or Folder" resolution will be applied to all the selected conflicts.
You can also use the command-line tool tf resolve /auto:OverwriteLocal to resolve the conflicts.
Grant's answer is great for how to resolve multiple conflicts.
As for why you have those conflicts, generally speaking, your TFS client has detected that a file exists locally that is not managed by TFS, but you are trying to perform a get operation that would overwrite that file.
If you're following a normal development workflow (and not going and editing files outside of your editor), the most common source of writable conflicts is from shelvesets. If you were to pend an add on a file, then you were to undo that add (either explicitly or because you shelved the change and deselected the preserve pending changes button), the file is not deleted. (This is to prevent data loss - it's not uncommon that you would want to create a file but not have it checked in to source control.)
Now if you (or someone else) were to check in that shelveset (either through creating a build from that shelveset, or from gated check-in, or because your code reviewer checked in your shelveset directly), then when you do a get latest, your TFS client will detect that the file still exists locally and thus, you'll have a writable conflict.
This may not be particularly obvious in the case of gated check-in. How gated check-in actually works is when you try to check in your changes, your check-in is actually converted to a shelveset. The TFS build agent will then try to build your shelveset, and if the build succeeds, it will then check-in that shelveset on your behalf. If the build fails, the shelveset remains and you can unshelve to fix the build errors.
For this reason, it's important to run the build notification application when you're using gated check-in, which will allow you to "reconcile" your changes once they're submitted. Reconciling your check-in will simply do a get of the check-in that was submitted by the build server, but it will avoid conflicts since it understands the context of the changes that are on your local disk. (It will compare the contents on your local disk to the contents on the server.) If you do not choose to reconcile, you will, unfortunately, have writable conflicts on files that were added.
(Note that this scenario will not produce a conflict in the next version of TFS - if there are no content differences, TFS will not produce a conflict.)
You can do it for whole folder, multiple folders or entire project where conflict files exist.
You need to right click on that specific file/folder, go to Advanced, Select "Get Specific Version..."
You must have all Rights (Full control) to a specific local file or folder. Check it out. If it's not true you have to delete all local files, change Rights and then get latest files from server.

Resources