When you write some kind of automation (script) which needs to interact with git and clone/pull data and perform some action. And if its behind authentication layer then you need a way to automate the authentication that can let you pass credentials and automation can run without any interruption.
Either you can use ssh keys to authentication and use git@ URL to access your git repo.
But if you want to access (or force to) git via https URL you need to pass credential explicitly.
There are 2 ways to achieve this task for http protocol.