Exercise - Use branching and merging with Git

Completed

This exercise is written to use the Cronus sample company from the US version of Business Central. You might need to make adjustments to the steps if you use the sample company from your country or region.

Scenario

You want to develop a new feature, but prefers to create a separate branch for the feature development. You want to enable branch policies on the main branch, to force the use of pull requests.

Tasks

  • Set branch policies on a remote main branch

  • Create a new feature branch in the remote repository

  • Pull the new feature branch locally

  • Add a new file to an AL Project

  • Push the modifications to the remote feature branch

  • Create a pull request to merge the feature branch into the main branch

Steps

  1. Open your favorite web browser, and then open your Azure DevOps organization.

  2. Open the Hello Business Central project (or another project) and select Branches in the Repos section in the left menu.

  3. Hover with your mouse over the main branch. This displays three vertical dots at the end of the line. Select Branch policies from the menu.

  4. Enable Require a minimum number of reviewers and Allow requestors to approve their own changes. If you're the only one in the organization, you can set the Minimum number of reviewers to 1. Select the Save changes button to save the branch policies.

  5. Select Branches in the Repos section in the left menu, and then select the blue New branch button on the top of the page. Give the new branch the name feature-linkedin. Select main as the branch Based on, and then select Create.

  6. Open Visual Studio Code and press F1 to open the command palette. Type: Git: Fetch and select the command. This retrieves changes from the remote repository.

  7. Select the main branch button in the left bottom corner. This opens a list where you can select your branch. You see a branch origin/feature-linkedin. Select that branch to create a local branch linked to the new remote branch.

  8. Create a new table extension in a new file by using code snippets. Type ttabext and press the TAB key.

  9. Change the ID in 50100 and the name in SocialMediaExt. It extends the Customer table.

  10. Add following field LinkedIn. It has a datatype Text[250].

  11. Open the Source Control view and add the newly created file to the staging area.

  12. Add a commit message Added LinkedIn, and commit your changes to your local repository.

  13. Use the sync button to synchronize your changes with the remote repository.

  14. Open Azure DevOps, and go to branches. You should see a box indicating that your branch contains changes. Select the create pull request button.

  15. Your pull request should merge from feature-linkedin to the main branch.

  16. Add yourself as reviewer and optionally other persons in the organization.

  17. Select the Create button to save your changes.

  18. In the pull request window, select the approve button, and then select the blue complete button.

  19. In the complete window, select the delete the branch after merging option.

  20. The pull request should now be completed, and your changes merged into the main branch.