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.
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.
Install TFS 2015 Power Tools
Create a shelveset of your changes
Open the Developer Command Prompt
Use the tfpt unshelve /migrate command as such
tfpt unshelve /migrate /source:$/Project/Branch1 /target:$/Project/Branch2
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.
Related
I downloaded Team Server Power Tools (TFPT) to be able to take a shelveset that was created on one branch and unshelve it on another. But for some reason, TFPT insists on asking for the target server path, which I find a bit ridiculous since it should be visible to TFPT.
A quick look around, it appears that there is an API that will state the server path, but I would rather have this available through scripting. Is there a way to get the server path through scripting?
If you have a shelveset called MyChanges on the Main branch in a Team Project called MyProject and you want to unshelve it to the Dev branch instead then the tfpt command would be:
tfpt.exe unshelve /migrate /source:"$/MyProject/Main" /target:"$/MyProject/Dev" "MyChanges"
I'm trying to unshelve a shelveset using the command line with team explorer everywhere. I keep receiving this error:
An error occurred: TF400016: Unshelve with Merge is not supported on the version of Team Foundation Server on which your team project is hosted.
The shelveset is on the same branch as the one I'm trying to unshelve onto. I've run tf undo -recursive . before trying to unshelve and it tells me there are no pending changes, so I'm unsure why it is trying to merge. Has anyone had any success with this? Thanks for the help.
Has the file changed in tfs since the shelve set was created? I have seen the same problem if you try to unshelve a set from previous version of the file over a subsequent version. To resolve, you can pull the code that matches the shelve set, then unshelve, then get the latest code and the merge will happen correctly.
I use TFS with Jira to managment my team tasks.
I want to integrate a Code Review tool at development process.
When i try to use crucible i reveal that it not support TFS.
I want to know if , there is a good and credible solution for this ,to enable me use crucible with TFS.
additional , if there are another suggests for code reiview tool for VS and JIRA.
Thank!
Some time ago we decided to run Crucible on our project. Our project uses TFS 2012. We use one branch in TFS called 'dev' as a trunk, i.e. branch where developers make commits and where raw code located. Second branch where release code located called 'main'
Our workflow for peer review was:
Make some changes and shelve code
Send email to reviewer
Reviewer doing review in some custom tool and send email with notification that he is done
Commit code into 'dev' branch on TFS
Wait while build-server makes successful build
Commit to 'main' branch where production code resides
Our goal was to improve step 2 and 3. Crucible is great tool, but it doesn't support TFS out of the box, thus we decided to use some TFS bridge. Actually, there are two main options either using tfs->svn or tfs->git. Finally, we decided to use tfs->git bridge, because creating branches in git extremely cheap and it might have been helpful (it did), because we was thinking use branches in git for out shelvesets in TFS. Finally we made our mind to use git.
So far I know only 2 options to convert TFS into git:
git tf - this one works on Linux and recommended by Microsoft
git tfs - this one works only under Windows, but we choose this one, because of large set of commands
We need to convert TFS branch into Git repo and maintain our git repository in fresh state. We don't work with git to push new changes back into TFS, we need git repo only for Crucible.
There are steps we made to achieve the goal:
1. Firstly, we cloned our TFS "dev" branch into "dev" repo. We needed only this one branch, and we haven't any back merges from "main" branch. We have tried to do this with clone command, but without any luck:
git tfs clone http://tfs:8080/tfs/DefaultCollection $/SOME_PATH/dev
This command cloning full history from TFS, but it seems our TFS branch quite large and at some time git-tfs crashed with System.OutOfMemoryException exception. Another time, we failed with exception that max limit of path was exceeded, we found workaround by mapping workspace dir into as short path as possible as follows:
git config --global git-tfs.workspace-dir e:\ws
When we failed with clone command, we went to use quick-clone command. This one cloning starting from any time in history, from any changeset.
git tfs quick-clone -c545532 http://tfs:8080/tfs/DefaultCollection $/SOME_PATH/dev
Option -c545532 here is the number of changeset to starting copying from. Once per year we update all our source files with new header, thus we just to copy from beginning of current year. In that way we should have all necessary history to make branches from shelvesets.
If you hadn't used -c argument here, you would have haven't any history at all, because quick-clone copies just history if you asking for it.
Once repository was cloned, we had written "script" and put it into task scheduler to run every 5 min. What script is doing is just checking for new commits in TFS and creates new branches on our git repository. Again, we use git-tfs here. To get all new commits we call pull command:
git tfs pull
To unshelve TFS shelveset into particular git branch we use unshelve command:
git tfs unshelve -user=TFSDOMAIN\Username "Shelveset Name Here" Branch_Shelveset_Name_Here
This last command creates branch 'Branch_Shelveset_Name_Here' in git from shelveset 'Shelveset Name Here' in TFS. A shelveset's name can contains spaces and some escape chars, so our "script" clean up such cases. As I said, creating branches very cheap on git, thus we haven't any problems with this. If something was pushed into git repo we call crucible API to refresh it.
BTW: To make git repo visible in network I just installed SCM-Server. Crucible was installed and configured to use our domain username/password, thus we get email notification as well. As result we drastically improved step 2 and 3 from our workflow and it works for few months and we are happy with it.
Our workflow became:
Make some changes and shelve code
Wait for our shelveset in crucible (about 6-8 min), create review
Reviewer doing review in crucible
Commit code into 'dev' branch on TFS
Wait while build-server makes successful build
Commit to 'main' branch where production code resides
While working with this I noticed few issues:
Issue1: If you added new file into project and shelved it, you would not see it in git repo, because git-tfs can't find parent commit for it. I'm not sure is it bug of this tool or not, but simplest workaround for this, is having at least one file in shelveset with existing parent. For example, you have added 2 new files and want to send it for review. Instead of creating shelveset with these files, just touch any file which already in git repo (make it pending in Visual Studio), finally you will be able create shelveset with three files (2 new files [add] and 1 for edit [edit]). In that case everything works and git-tfs can unshelve TFS' shelveset into git branch., i.e. we can see it in crucible.
Issue2: One day our HEAD in git repo became detached from "master" branch. Once that happened crucible didn't see new changesets. I have fixed it with command:
git rebase HEAD master
I have created picture how this everything works on our project, may be it could be helpful:
You can integrate Mira and TFS with TaskTop and then use the code review tools built into Visual Studio.
Code Review added in Visual Studio 2012
TaskTop integration with TFS & Jira
These I think are your best options.
I'm trying to use tfpt to migrate a shelveset from a source branch into a target branch, but it doesn't appear to do anything...not that I'd expect much more...but any chance anyone knows what's wrong? I'm following the instructions correctly I think...
I've got:
tfpt unshelve "DbMigrations" /migrate /source:$/TeamProject/Main /target:$/TeamProject/Releases/7.20
What happens after you run the command? You need to have a few things set up before migrating:
A workspace that encompasses both the source and target branches.
You need to run the command in a folder within the source.
Once you run the command you should be asked to merge the changes from the original shelfset into the destination branch and resolve any conflicts, which finally pends a changeset on your client. Nothing is touched on the server until you check that changeset into TFS itself.
I experienced the same problem and I could not get it to work by specifying the shelveset name. However, I discovered that if you remove the name of the shelveset altogether, TFS will pop up a window with a selection list of available shelvesets to choose from. Select the desired shelveset and perform all other merge operations as per normal.
Example: c:[mapped workspace target path] > tfpt unshelve /migrate /source:"$/Sourcepath" /target:"$/targetpath"
You need to use the branch paths on the TFS server, not your local machine. To find the paths, go to source control explorer in visual studio, right click the branch, advanced > properties, and you want the branch name, not the local path. If the path has spaces, wrap it in double quotes.
I've edited some files in Branch1 and found out I would like to check the pending changes in to a new branch, Branch2. Is this possible?
I know I can create the branch as normally and then copy all the changed files to Branch2 by hand but that can be cumbersome.
You can shelve your changes and the unshelve them into another branch: Can I unshelve to a different branch in tfs 2008?