Source Control Setup

Coordinator
Sep 3, 2013 at 1:57 AM
Edited Sep 3, 2013 at 4:46 AM
WHY SOURCE CONTROL?
During team development, a member may accidentally delete, remove, or modify certain things that might create frustrations to the entire team. Source control can help the teams quickly revert to a certain state prior to the disaster in these circumstances. Moreover, when one developer has changed something and wished to synchronize the changes to everyone, without source control, one might need to use primitive ways like E-mailing codes to each team member, and this is error-prone and lowly efficient. These situations are really not uncommon during modern developments, . We need to learn it now or later if we're to work for software companies. My personal experiences at AMD and Microsoft told me that maybe every software company in the world is using some kind of source control to protect their work.

SETTING UP OUR SOURCE CONTROL
If you have heard about SVN or Github before, you probably know they are examples of source control tools that are widely used. But if we use Microsoft technology, there’s a very simple yet powerful source control tool built into Visual Studio. It’s called Team Explorer. You can connect to Team Foundation Servers using Team Explorer to host your codes on the servers. To do so, please:

1) Visit our Source Control Server at https://pennapps.codeplex.com/.

2) Register yourself in the site. If you have a Microsoft Account (a Hotmail account, a MSN account or any Email address ending with @hotmail.com, @live.com, @outlook.com), you can sign in using that account.

3) Log in to the site with your account. Now visit https://pennapps.codeplex.com/, and click on PEOPLE tab. Please apply to join in the team and I will add you as a member the moment I receive your application.

When you become a member of the team, please continue the follow steps:

4) Open your Visual Studio. Select TEAM tab. Then select Connect to Team Foundation Server. You might notice the servers drop down list is empty. This is natural since Visual Studio doesn’t know you well, yet! Now click on Servers button.

5) In the dialogue box, click Add. You will see another dialogue box that asks for a lot of credentials.

6) Now please navigate back to https://pennapps.codeplex.com/ and this time click on SOURCE CONTROL hub. Click the Connect button below it. Then a prompt panel will tell you everything about your credentials.

READYING YOUR SOURCE CONTROL
Now the following steps will guide you to pull projects/settings from server. Before that, here is a quick note about how Visual Studio organizes your projects. Basically, every Visual Studio window can host one solution, and each solution can hold multiple projects. Inside each project, you can have multiple items (source files, icons, translation files, settings and others). The following steps will guide you to pull your projects from server to your machine.

1) Please click VIEW tab in your Visual Studio and select Team Explorer. The Team Explorer panel should appear on your right.

2) Now click the home button. You should see a link named Source Control Explorer. Click that link. The Source Control Explorer will give you everything that belongs to your team.

3) Please notice on the left you should see a folder called PennApps – and that’s the source files on the server. Also please notice that on the upper right there’s a Local Path: Set. This means that although the source files on the server are found, they are not on your local machine yet. You should tell where Visual Studio should put those files on your local machine.

4) Now click Set and choose a folder that is most convenient to you to put those source files. Mine is at E:\Programs\PennApps.

5) Once you selected a local path, you can issue a Get Latest Version command to ask Visual Studio to download everything to your local machine. You can do so by right clicking the PennApps folder.

6) Now please click the PennApps folder on the left. On the right panel, you should see another PennAppsExperimental folder. Now please enter that folder and double click PennAppsExperimental.sln (the .sln extension is short for solution, meaning this is a solution file that can contain projects).

7) Visual Studio should now open that solution for you. Inside that solution, you can see a project with the same name on the right panel (solution explorer). If you don’t see the Solution Explorer, you can open it by clicking VIEW tab and selecting Solution Explorer.

8) Now you should notice the entire solution has been downloaded to your local computer.

BASIC SOURCE CONTROL WITH CHECK-IN AND CHECK-OUT
In this section we will understand how to perform basic source control activities and synchronize code across the entire team.

As you might have noticed, there’s a blue lock on each of the items in the solution. That blue lock means that item is under source control. Notice the source control is recursive, meaning that if the parent item is under source control, all its children will be under source control too. Visual Studio organizes items using a tree view, so the indentation will tell you the relationship between items.

1) If you wish to modify an item, you can first check that item out for edit. When you check out an item, you are essentially saying that you are working on that item and you do not want anyone else modifying it. In this case, all other team member will notice a yellow lock icon before that item, meaning that item has been checked out for edit by someone else, and you will notice a small red tick icon before that item, meaning it’s been checked out by you. If you do not check out an item before you edit it, Visual Studio will perform a check out for you.

2) If you wish to submit an item that you just modified, you can check in that item. By checking in an item, you’re essentially saying that you’ve done modifying it and it’s ready for everyone else to use.

3) If you want to synchronize with the entire team, you can issue a Get Latest Version command, this command tells Visual Studio to pull the latest everything to the local machine. So you will see the latest of the team progress.

HANDS ON LAB

Now please click the program.cs (the .cs extension means C# source code. In case you’re interested, C# (pronounced as C Sharp) formally shouldn’t be written as C#, it should be C♯. And that ♯ (sharp) is from the staff in music recipes, meaning to raise the tune a little bit. However people find it so difficult to type the ♯ sign, so it was replaced by #. And that’s why C# is written as C# but is pronounced as C♯. Now C# has the 4~6th largest developer population in the world and is consistently used in every Microsoft technology). Modify the following line:
Console.WriteLine(“Hello PennApps!”);
To
Console.WriteLine(“Hello PennApps2013!”);
And issue a Check-in.

FAQ

1) What if two people check out an item simultaneously and made different changes?
A piece of software called Conflict Resolver will be invoked to let you choose which one to save to the server.

2) What if I was modifying an item that I checked out for edit but someone tells me that he has modified another item and I rely on that item to work? Should I issue Get Latest Version?
Yes, but you can issue Get Latest Version only against that single item. If you issue Get Latest Version against the entire solution, your unsaved item/unchecked-in item might be lost. But don’t be alarmed, Visual Studio will ask you before anything bad happens.