Basics
Most people I talked to are using origin and remote as an equivalent, but the aren’t. Origin is the default name for the remote repository from which the project has been originally cloned. Normally that is the only remote that is getting used, but in some scenarios you have to use other as well.
Function | Command |
---|---|
Show | git remote -v |
Add | git remote add <name> <url> |
Remove | git remote remove <name> |
Rename | git remote rename <old> <new> |
Scenario
You have cloned a repo and have build a software from that code. Then a user/company has forked that repo and done some changes. You just like some of the changes they have done and you only want to get them. This means you have to cherry-pick commits from another remote then the one you have cloned from.
$ git remote add fork https://example.link/repository.git $ git fetch fork $ git cherry-pick 774d3d62dd70cde1f8b0b8b07ecac01e6c1c6c0e