toobee
toobee

Reputation: 2752

Git push local repository with all branches as-is to remote repository

I want to make my local version of a repository (not a single branch, all branches) the new remote version.

Is there a way how to do that or do I have to overwrite/add each branch manually? It is not an initial commit. I just want to overwrite everything that is online with a local version that is more correct than the one currently online (after some bad git operations I want to restore it with a backup version).

Upvotes: 1

Views: 31

Answers (1)

Nils Werner
Nils Werner

Reputation: 36765

You can use

git push origin --mirror

From the manpage

--mirror

Instead of naming each ref to push, specifies that all refs under refs/ (which includes but is not limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the remote repository. Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end. This is the default if the configuration option remote.<remote>.mirror is set.

(emphasis mine)

Upvotes: 3

Related Questions