In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Today, I will talk to you about the introduction of the source code control tool TFS, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
We know that work items are the basic elements of project management, but work items alone are not enough for the success of a project. Work items describe what to do (such as tasks) and what went wrong (such as Bug). In addition, we also need to write the program line by line. TFS's source code management control system can help us manage this line of code, file by file, and modify again and again until the product is released.
1. The basic scenario of TFS source control system.
Here's how to use the source control system in Visual Studio.net. We know that Visual Studio IDE can be integrated with Visual Source Safe and other source control systems, so we first need to choose what to use to control the source code. This can be done by selecting "Tools"-> "Options" from the IDE menu, and in the options dialog box, find source control (Source Control | Plug-in). Then select Visual Studio Team Foundation Server:
2. How to add a project to source control
First of all, we need to have a team project. Let's take the existing team project TFSTest in the test environment as an example. When we add a source code project to the source code management system, Visual Studio will create a Workspace for you.
A workspace is the mapping of files and directories on the client side of the server. When a user adds, edits, deletes, moves, renames, or other actions to a target in source control, the user's changes are retained in the workspace and marked as pending / uncommitted modifications (Pending Change) in the workspace. Only after these changes are checked in by the user (Check In) will the files or directories on the server change accordingly.
Let's show you how to create a new solution and project and add it to source control:
In Visual Studio IDE, create a new project and select add to Source Control (Add to Source Control):
The integration environment starts to create the framework of the project in the background, and then prompts you to choose which Team Project to add the new project to the TFS. Here, we select the TFSTest project and click OK:
Then, we open the menu View-> other Windows-> Source Control Explorer:
You can see the newly added ITRequestFormPrj1 under the TFSTest team project:
There is a yellow + sign in front of the project folder, indicating that these are all Pending Change.
If we need to add an existing solution or project to TFS, we can open the solution or project, then right-click the solution and select add solution to source control:
Then in the pop-up window, select to add the solution to that Team Project.
Now let's try to compile the project (simulate to verify the correctness of the code), then check the Pending Change into TFS and select View-> other windows-> pending changes:
You can see what Pending Change is currently available:
Then click the check-in button and all selected Pending Change files will be checked in.
Let's see what happens if you add a file to a project that is already under source control:
First, the project is automatically Check-Out, with a red tick icon in front of the project (left below)
Second, the new file is preceded by a yellow + sign, indicating that this is a pending modified file (right below)
Check in the Class1 file first, and then we try double-clicking to open the Class1.cs file and enter a line of comments. We find that after editing the file, the file will be automatically checked out (Check-Out). Because the file is Check-Out, the status of the project has also been updated to Check-Out:
3. How to synchronize with the server
In an environment where teams work together, many people are modifying the code in the same project, and you need to download the latest changes in the project locally. Do the following to synchronize your workspace with the latest version on the server:
In the solution window, select the project or the entire solution, right-click, and select "get latest version"
In source code explorer, select a Team Project to synchronize the latest version of the team project locally:
If you select a solution folder under a Team Project in the above figure, you can get the latest version for a solution.
Before checking in your own code, it is best to synchronize the latest version on the server, this process needs to resolve possible version conflicts, and then you need to build the project to make sure there are no problems before checking in the code. This is to try to avoid the code you check in, resulting in build failures on servers and other developers' machines.
4. How to do Check-In
The following three methods can do check-in (Check-In)
In the solution window, right-click the modified file and select check in
In the source control window, right-click the modified file and select check in pending changes
In the pending changes window, after selecting the file you want to check in, click the check in button:
This method allows us to quickly check in. By default, all modified files are automatically listed. After determining the files to be checked in as needed, you can fill in the checked-in comments and associate the corresponding work items with the checked-in changes:
Relevant reviewers who fill in the code:
Check to see if the scheduled policy has been met:
When the user chooses to check in, all selected files, check-in notes, and work items associated with the check-in are stored in the database as a new change set (Changeset). A change set is a separate entity composed of file versions, related work items, and source control metadata (Metadata).
If the work item has relevant process processing rules, these rules modify the status of the work item. For example, a team might define the following rule: if you manage a work item when you check in and select check-in Action to solve, the work item changes from active to resolved:
5. How to branch and merge
The concept of Branching is supported in TFS. The so-called branch refers to copying a copy of files and directories in the source control system. Branches can maintain the history of files and directories, and can merge changes from old files into new ones. The modification on the new branch has nothing to do with the original branch (commonly known as the primary branch).
Merging refers to merging files (files, directories, team projects) from different branches together. In a merge operation, one branch is the source branch and the other is the destination branch. The source branch includes the files that the user wants to merge.
Consider the following situation:
Under the requirement of time, we may have to release a version first, so we can set up a branch of Release1, and then the main branch code and branch code continue to be developed at the same time. At some point, the two branches can be merged.
Here is another scenario for branch applications:
Under the requirements of functional subdivision, for example, Visual Studio is divided into several versions: Express version, standard version, enterprise version, architect version, and so on. They have common basic functions, and after the development of these functions, they can realize the development of value-added functions in different versions through branches, such as spending function An and function B from the main code.
It is also possible that these value-added features are not required, if it can be implemented, we will merge into the main code, if not, cancel the merge.
From the above scenario, you can see that branches provide more flexibility for code management.
5.1 create Branch Operation Demo
It is very convenient to branch in Visual Studio. First, let's create a branch:
In the source code manager window, select a project that you want to branch, such as the ITRequestFormPrj1 in the following figure, and then right-click to select Branch:
Here, you can choose the name of the branch, branch the latest version of the main branch or the specified version, and whether to create a local copy of the new branch (that is, download the new branch from the TFS server to the local workspace)
After clicking the OK button, we begin to create the branch. After the creation is successful, in the source code manager window, we can see that there is a two-way arrow icon between the main branch and the new branch to indicate their relationship:
5.1 demonstration of merge branch operation
Let's first try to modify the code in the new branch, and then check in the changes, and then we demonstrate the operation of merging branches:
In the source code manager window, select a branch, merge it into the main branch, right-click, and select merge:
In the source control merge wizard, the selected branch is used as the source branch, and the target branch is automatically identified:
In the image above, click the next button, and the wizard will prompt you to select which version of the source branch to merge:
Once confirmed, the wizard prompts you that you may need to resolve the conflict:
Click the finish button. If there is a conflict between the merged branches, you will be prompted to resolve the conflict before merging:
Click the resolve button to indicate that there is a conflict in the Form1.cs file:
Click the compare button, and in the comparison window, the differences of the same file in the two branches will be displayed:
In the previous window, select merge changes in merge tool and click the OK button:
The backstage will launch the merge tool for you. You will need to wait a moment:
In the merge tool, you can select changes on one side to apply, and if there are multiple inconsistencies, you can easily navigate through previous and next changes:
After selecting a change, you can also make the final changes in the bottom editing window, and then click OK:
Prompt that the conflict has been resolved. If you want to save the file, click:
When all conflicts have been resolved, click close, exit conflict processing, and complete the merge operation:
At this point, we open the merged target branch, because the modified content is merged into the target branch, and the corresponding file of the target branch is in the pending change "merge, edit", which needs to be checked in before the latest content can be submitted to the TFS server:
6. What is on the shelf and off the shelf
The Shelve and UnShelve commands don't sound easy to understand. We might as well imagine that you are sitting on your desk to draw a picture. Suppose you are using meticulous brushwork to draw a picture of Qunfang Night Banquet in a Dream of Red Mansions, and the sketches of beauties, large and small, are all over the table. This is another thing you have been ordered to do: splash ink painting, and you only have one desk. What if you splash ink on the beauties? So you roll up all the current drawings and put them on the bookshelf. This is the equivalent of being on the shelves.
Then you start the work of throwing ink painting. After sprinkling as much as you like, clean the table, take all the drawings you just put away from the bookshelf, spread them out, and continue your Qunfang dinner picture. This is equivalent to taking it off the shelves.
These two commands are mainly used to:
Save your current job and switch to another task
Others start code review (you will modify the shelves, and others can take your content off the shelves in their own environment, and then do a review)
Integrate other people's changes (two people's changes depend on each other, which can be integrated through the on / off command)
This multi-person collaboration provides a convenience: you don't need to Check-In every time, and then others Check-Out, but after many times on and off the shelves, you can have a final Check-In.
The operation on the shelf is very similar to the check-in operation. In the source code manager, right-click the file to be put on the shelf and select "shelve pending changes":
All the parameters are similar to the check-in operation, except that the modification does not check for conflicts and does not affect the source code (that is, it is not really Check-In, which can be confirmed by a red tick mark in front of the verification file after the shelf operation), but is temporarily stored on the TFS server so that others can take it off the shelves:
After reading the above, do you have any further understanding of how to get started with the source code control tool TFS? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.