Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2015 - Check in to a different branch in TFS

I checked out some files from the main branch of our code set in TFS. Later, a separate branch was created. I would like to check in my code to the new branch, even though I originally checked it out of the original one. Is this possible?

EDIT: I know I can check in to the main branch and do a merge, but I'd like to avoid that if possible.

like image 648
Harlan Wescott Avatar asked Apr 18 '16 21:04

Harlan Wescott


People also ask

How do I change branches in TFS?

To switch to a new branch, a database must be unlinked from source control (unlinked from the current branch), and re-linked to a new project (folder) that represents a newly created branch.

How do I switch to a different branch in Visual Studio?

Access the "Source Control" tab on the left side of VSCode. Click on the "three small dots" next to the refresh button. Click on the "Checkout to..." option. Choose the branch you want to switch to.

How do you handle branches in TFS?

With TFS, there are several ways that you can handle releases. You can tag/label each release branch or bug fix. But the relationship between release branches and the release is not always clear. Teams need to create a naming scheme and define a TFS branching strategy to help document the flow of change.

How do I branch a TFS file in Visual Studio?

In Source Control Explorer, right-click the folder or file that you want to branch, point to Branching and Merging, and then click Branch.


2 Answers

I couldn't do with the answers using Power Tools, so I checked in on the source branch, merged to target, and rolled back from source branch.

like image 50
Bruno Peres Avatar answered Oct 04 '22 23:10

Bruno Peres


Well, it's based on which version control you are using.

If you are using GIT, it's simple. After you created the new branch in the UI, you just need to do a 'check out' of the new branch. Any uncommitted changes will be automatically point to the new branch. You can then commit them there.

If you are using TFVC, you need to shelve your changes on the original branch and unshelve them on the other branch. This functionality is provided using tfpt unshelve /migrate command. More detail steps please refer the question: TFS: submit changes done locally in one branch to another branch

It's also a sample which shows the difference between GIT and TFVC.

like image 23
PatrickLu-MSFT Avatar answered Oct 04 '22 23:10

PatrickLu-MSFT