简体   繁体   中英

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).

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM