GoLand 2021.3 Help

Add files to a local Mercurial repository

After a Mercurial repository for a project is initialized, you need to add the project data to it:

  • If you have specified Mercurial as the version control system for your project in the Settings dialog, GoLand suggests to put each new file under Mercurial control during the file creation.

  • You can add all unversioned files to Mercurial control or select files to add.

To add all currently unversioned files to Mercurial control

  1. Open the Commit tool window Alt+0

  2. Navigate to the Unversioned Files node and choose Add to VCS from the context menu.

To add specific file(s) to a local Mercurial repository, do one of the following:

  • Switch to the Commit tool window Alt+0, expand the Unversioned Files node, and select the files to be added. From the context menu, choose Add to VCS.

To specify the commit options

  • If you need to perform pre-commit checks, upload files to a server after the commit, or commit with advanced options, click the Gear icon:

    • In the Before Commit area, select the actions you want GoLand to perform before committing the selected files to the local repository.

      The following options are available:

      • Reformat code: perform code formatting according to the Project Code Style settings.

      • Rearrange code: rearrange your code according to the arrangement rules preferences.

      • Optimize imports: remove redundant import statements.

      • Analyze code: analyze modified files before committing them. Click Choose profile to select an inspection profile from which the IDE will run inspections.

        For example, GoLand can display a notification before you commit your changes if you replaced local paths in the go.mod file. This might help you to avoid situations when these replacements are committed by mistake.

        To enable the feature, you must select the Analyze code checkbox in the Commit dialog settings.

        Notifications about replacements of local paths in the go.mod file
      • Check TODO (<filter name>): Review the TODO items matching the specified filter. Click Configure to choose an existing TODO filter, or open the TODO settings page and define a new filter to be applied.

      • Cleanup: batch-apply quick-fixes from code cleanup inspections. Click Choose profile to select a profile from which the IDE will run inspections.

      • Run Tests: run tests as pre-commit checks. Click Choose configuration near Run Tests and select which configuration you want to run.

      • Update copyright: add or update a copyright notice according to the selected copyright profile - scope combination.

      • Go fmt: format your code with go fmt. For more information about Go tools, see Go tools.

  • Switch to the Project tool window and select the files to be added. From the context menu, choose Mercurial | Add to VCS.

Last modified: 19 March 2022