How to add a git repository to a composer.json file in Drupal 9

  1. Fork a Github module like and change the composer.json like
@@ -1,5 +1,5 @@
-  "name": "protitude/markdown",
+  "name": "asanchez75/markdown",
  "description": "Allows content to be submitted using Markdown, a simple plain-text syntax that is transformed into valid HTML.",
  "type": "drupal-module",
  "homepage": "",
  1. in the composer.json file of your Drupal 9 installation add the following lines
    "repositories": [
            "type": "composer",
            "url": ""
            "type": "git",
            "url": "",
            "reference": "8.x-1.x"

  1. Run this command to retrieve the module from Github (dev plus the branch name)
composer require  asanchez75/markdown:dev-8.x-1.x