The following use case can occur when developing drupal: you want to patch a module, but it is a contrib module that is not in version control (it is ignored by git and gets downloaded on build). Therefore you can not use the standard GIT commands for creating a patch.
So, you would have to download the module separately, like:
git clone --branch 8.1.x http://git.drupal.org/project/colorbox.git
Then, you make the change and run the following:
git diff 8.1.x > colorbox-css-issue.patch
This creates a patch for this module. Now you can place the patch in a patches folder and add it to your composer.json file. Helpful source: https://www.drupal.org/node/707484