11

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.

Harlan Wescott
  • 279
  • 2
  • 7

3 Answers3

13

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.

Community
  • 1
  • 1
PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
9
  1. Install TFS 2015 Power Tools

  2. Create a shelveset of your changes

  3. Open the Developer Command Prompt

  4. Use the tfpt unshelve /migrate command as such

    tfpt unshelve /migrate /source:$/Project/Branch1 /target:$/Project/Branch2

Null Reference
  • 11,260
  • 40
  • 107
  • 184
3

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.

Bruno Peres
  • 2,980
  • 1
  • 21
  • 19