Mats Isaksson
Mats Isaksson

Reputation: 1959

Create branch from main with local changes included, or create branch from shelveset

I have been working in our main branch for some time, but now realize the changes were more comprehensive and should be developed in a dev branch instead.

Therefore, I want to create a dev branch from our main branch with my local modifications in main moved to that branch. There seems to have been a way with older versions of VS and TFS, using tfpt commands, but I cant find out how to accomplish this with newer environments, I have VS2019 professional on my machine, and we are using TFS 2017. (The old solution was described here).

If the procedure described previously could be adopted with modifications or with a nice hack, a How-to for that would of course be highly appreciated.

Upvotes: 1

Views: 2324

Answers (3)

Anker Peet
Anker Peet

Reputation: 51

You can accomplish this in Visual Studio by doing the following:

  1. Select the "Team Explorer" tab
  2. Select the "Home" icon at the top
  3. Select "Changes"
  4. Click "Stash" => select "Stash All"
  5. Create your dev branch, or just switch branches if it exists
  6. Right click on your "WIP" in the "Stashes" section => hover over "Apply" => select "Apply All as Unstaged"

Upvotes: 1

PatrickLu-MSFT
PatrickLu-MSFT

Reputation: 51073

According to your description and solution shared in your question. It's actually talking about how to unshelve a shelveset to another branch in TFS.

Without using tfpt unshelve /migrate command, there isn't any better way to handle this in Visual Studio 2019.

In your situation, a not smart workaround to solve this should be: First back up your local files on main branch, undo your pending changes, create a new dev branch based on main branch. Get latest version from sever side of dev branch to your workspace.

Then copy your back-up files/folders which copied from main branch to the new dev branch. Windows system will judge to replace files and add new files.(It may take some time) After this, TFS system will auto detect the changes in local and will list them as new pending changes for dev branch. Some new add files maybe stay in the Excluded list, manually promote them in Included list.

After this, you could also consider to use Git. 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.

Upvotes: 0

Shayki Abramczyk
Shayki Abramczyk

Reputation: 41545

As you said, the tftp command is part of Visual Studio Power Tools that doesn't exist for VS 2019.

As workaround, you can do this:

1) Copy all the changed files to another location (locally).

2) Undo pending changes.

3) Create the new branch.

4) Delete the changes file locally and copy there the new files (that you backed up in step 1).

5) Check in the changes.

Upvotes: 1

Related Questions