git remote add origin <repo_url>
Links a local repository to a remote one.
This command is used to create a new connection with a remote repository.
It achieves this by creating a new 'remote' configuration with the 'origin' alias that points to the provided <repo_url>
. This allows us to interact with the remote repository using this alias, which means that instead of typing the full URL each time when pushing (git push <repo_url>
) or pulling (git pull <repo_url>
), we can use the 'origin' alias (git push origin
or git pull origin
).
Specific examples:
git remote add origin https://github.com/user/repo.git