Create a local Git repository

Completed

Once Git is installed and configured, you can start creating your local repository. There are two ways of getting a local Git repository:

  • Use the init command to initialize a local directory as your local Git Directory. Then you can push this local Git directory to a remote directory later.

  • Use the clone command to get a copy of a remote Git directory on your local machine. This will get all the files with the complete Git history (all commits).

Let's first focus on the local Git directory by using the init command. Open the project folder location using the command prompt and use the following command:

git init

This will create a hidden .git folder within your project directory. The init command won't create a project or create a new folder for your project. It will initialize an existing folder as a Git repository. So, you can always do this later even if you already created a number of files within that directory.

The init command is built into Visual Studio Code. A typical Business Central Extension scenario can be the following:

  1. Open Visual Studio Code.

  2. Open your Business Central Extension project or create a new extension using AL:Go!

  3. Select View in the menu and select SCM (Ctrl+Shift+G).

  4. Click the Initialize Repository button to execute the init command.

    Screenshot of the Visual Studio Code Initialize Git Repository button.

  5. You can also use View, Command Palette (Ctrl+Shift+P) and search for the Git: Initialize Repository command.

    Screenshot of the Git: Initialize Repository command search.

Once you initialize the local repository, you'll see a list of files that all have the status U, indicating that these files are untracked. These files are within the working directory, but they haven't been added to the Git repository. The list of files depends on your specific application, and which files you created. You can also see at the left bottom of your Visual Studio Code application, that you're using the master branch. The init command automatically generates a master branch in your local Git repository. All files that will be committed to the Git directory will now be committed on the master branch.

Screenshot of the list of untracked files marked with U.