$ git clone git@whatever.com/...
Cloning into example
$ git clone example example-2
This works even if you made uncommitted changes in your first clone. These uncommitted changes aren't copied. You can also check out an origin branch to not work with locally commited changes.
You can use git remote to set the new origin to upstream.
Or, you could use worktrees. That's fine too.
It doesn't, e.g. bare repositories don't have a worktree. This is useful for e.g. backing up a git repo to any SSH host by cloning a bare repository there and then adding it as an upstream of your local repo.
paradox460•6mo ago
For most other things, where unversioned files don't cause grief like this, a tool like jujutsu, which eliminates the whole stash dance, is generally better