This little dance is needed to merge in the remote origin/master to a fresh local (one created *without* cloning the remote, such as by a tool like [pass](https://www.passwordstore.org/)). I don't know if there is a better way?
You need to do this when
* you have another application which can use git for storing data, and you need to fill it with history from a common remote, but the application doesn't support `git clone`, only `git init` type operations
* you have a local repository with local changes that you want to keep, but still merge in the origin (although you could go the other way, I think?)
Use commands like these to merge in a remote to your local master, as the new origin:
```
git remote add origin git@github.com:user/repo
git fetch origin
git checkout origin/master
git checkout -b temp
git checkout -B master temp
git branch -d temp
git branch --set-upstream-to=origin/master master
```
An explanation of what these commands do:
* Add the remote, call it `origin`
* fetch the data
* switch to the `origin/master` branch just fetched
* create a new branch `temp` from the current branch (`origin/master`) - merges all the data to `temp`
* reset `master` from the `temp` branch - merges all the data to the local `master` branch
* delete the `temp` branch
* set *upstream* tracking for `master` as `origin/master`