Visual Studio Code and Code Versioning in TFS

    Version control is a framework that records changes to a document or set of documents after some time with the goal that you can review particular forms later. For the models in this blog, you will utilize programming source code as the documents being version controlled; however as a general rule you can do this with about a record on a PC.

    Below are version control types

    Local Version Control Systems:
    Many people’s version-control method of choice is to copy files into another directory. This approach is very common because it is so simple, but it is also incredibly error prone. It is easy to forget which directory you’re in and accidentally write to the wrong file or copy over files you don’t mean to.

    Centralized Version Control Systems
    In Centralized system, all files and historical data are stored on a central server. And developers commit their changes directly to that central server repository.

    Distributed Version Control Systems
    In a DVCS clients don’t just check out the latest snapshot of the files; rather, they fully mirror the repository, including its full history. Thus, if any server dies, and these systems were collaborating via that server, any of the client repositories can be copied back up to the server to restore it. Every clone is really a full backup of all the data.

    We will use Visual Studio Code, Git for Window and TFS for this blog. Please install Visual Studio Code and Git.

    Just for information, Visual Studio Code is new IDE for salesforce development. You can check another blog for working in this IDE for salesforce development.

    Let us integrate TFS (Team Foundation Server) with Visual Studio Code and Salesforce for code versioning and management. For code version and salesforce development below are steps.
    1. Code Cloning
    2. Development Changes
    3. Commit changes
    4. Pull Request

    Let us do every step one by one.
    1. Code Cloning
    Code clones are separate fragments of code that are very similar to master copy. Cloning is done so that we will get complete code and it will not impact running applications code.

    Let us see we have TFSDemoApp project, which is created in TFS. You can get this in TFS Code section.

    If we want to get clone of that application, click to get highlighted section, it will show below popup to get remote url for cloning. Click copy icon to copy remote url.

    Let us create a clone in local system. We need one folder where code will be copied. So create folder where you need to clone. After folder creation, right click on folder, this will open some menus with Git commands like below.

    Select Git Clone from menu. It will show another popup where you have to put remote url which is copied from TFS.

    You can specify branch also while taking clone. This will get complete copy of code in your local directory.

    2. Development Changes
    Once code is cloned, open that code in Visual Studio Code IDE. This will be look like this. Do your changes in code.

    As soon as code is change, it will show in upstaged list. See highlighted icon and object name.

    Move those objects into staged list so that it can commit to TFS. This can be done by right clicking objects and selecting Stage Changes.

    See highlighted area, one section STAGED CHANGES is created and selected objects moved to list.

    3. Commit changes
    Let us move these changes to TFS so that it will be used by other developer as well. Click on highlighted icon to commit your changes.

    It will ask comment to make an entry in code versioning. Put proper comment, what is reason for changing object. You can put bug # also here.

    Once commit is completed, code is committed in your local branch. We have to move that in TFS also so use command git push on terminal (View->Terminal).

    4. Pull Request
    Once code is committed to TFS, We can create pull request. Pull request is to merge your changes in originating branch. This request is done by developer and normally leads or code reviewer will approve/reject request.

    Once code is approved, code will be merged in originating branch.


    Code versioning is very important for any project to team collaboration, audit controls and backup. If any project does not have code management then that will be very prone to code failure.

    October 17, 2018 0 comment
    0 Facebook Twitter Google + Pinterest