kb/remote
Remote repositories in Git with push, pull, and fetch: origin, upstream, and `git remote add`. The difference between fetch and pull, and why `git push --force-with-lease` is safer than `--force`. Tracking branches, SSH keys, and GPG-signed commits and tags.
`git push --force` overwrites the remote history with yours. `git push --force-with-lease` does the same, but refuses if someone pushed there after your last fetch. Always use `--force-with-lease`.
Creates a local copy of a remote repository. Under the hood: `init` + add origin + `fetch` the full history + `checkout` the default branch. The first command you run on any project you did not create yourself.
Downloads updates from a remote but **does not touch** your local branches. Updates only refs/remotes/origin/. A safe command: after fetch you can see what arrived and decide what to do with it.
Fetches updates from a remote repository and merges them into the current branch. Essentially `git fetch` + `git merge` (or + `git rebase` with `--rebase`). The most confusing command for beginners.
Sends local commits to a remote repository and updates the branch there. If the remote received commits from someone else after your last pull, push will refuse until you synchronize.
Manages the list of URLs your repository is connected to. After `clone` there is one remote named `origin` by default. You can add a second one (`upstream` for fork flow), remove remotes, or rename them.
The link between a local branch and a remote one: "this branch of mine follows that remote branch." Enables `git pull`/`push` without arguments and `git status` messages like "ahead 3, behind 2."
Two conventional remote names. `origin` is where you cloned from (usually your fork). `upstream` is the "real" project you forked. This is just a convention: nothing is magic, both names can be renamed.