Integrated Version Control for Dynamics NAV in VSCode – How to create a new branch with Git
VSCode follows a design which offers an integrated work experience. Therefore is the creation and management of branches an easy task. This article describes how to create and manage branches with the integrated Git-support of VSCode.

The NAV Developer Preview Azure Image will install Git automatically. In case it is necessary to install Git manually, it is possible to download the installation files here. I have compiled general information about branches and how to utilize it here.

How to create a new branch
Create a new project using the command “AL: Go!” and a repository as described here.

After that, type “git create branch” in Command Palette and press Enter.
git create branch

VSCode will prompt for a name for the new branch.
git new branch name

VSCode does show the current selected branch in the lower left of the Status Bar.
git create branch

Now, let’s create a code change and merge it into the new branch.
git new branch code change

The code change will be transferred to Source Control by saving the file. Git will notify automatically that the saved file differs from the file stored in the branch and highlight it with a “M” for “modified”.
git new branch modified file

Now it is necessary to merge the latest changes into the version stored in the branch. I personally prefer the keyboard, so I type “git open changes” in the Command Palette. VSCode will show now the old version in the left window and the new version in the right window.git new branch merge window

It is possible to stage (or merge) a line individually or all together by executing the command “git stage all changes” using the Command Palette. The changes are now marked as “Staged changes” and it is possible to commit the changes to the branch using the command “git commit staged”. VSCode will prompt for a description which should be meaningful.
git new branch commit message

Using the command “git checkout to…” it is possible to switch between branches of a repository.

git checkout

Done!

More
articles

%d bloggers like this: