简体   繁体   English

git-如何替换Master?

[英]git - how to replace Master?


I have a remote repo where my project is out of date. 我有一个远程回购,其中我的项目已过期。
I made new one local repo with new project, switched to new branch and made what I wanted. 我通过新项目制作了一个新的本地仓库,切换到了新的分支,并做了我想要的。 Now I want to push it (not changes - whole project) to that remote repo. 现在,我想将其(而不是更改-整个项目)推送到该远程仓库中。 How should I do that? 我该怎么办?

The -f argument to git push is probably what you want, it allows the receiving repo to be overwritten with unrelated changes. git push-f参数可能是您想要的,它允许使用不相关的更改覆盖接收存储库。 The older changes in the remote repo will still exist for a time but eventually be garbage collected. 远程回购中的较旧更改将仍然存在一段时间,但最终将被垃圾回收。

When using git push you can specify which branch to push from and which branch to push to: 使用git push您可以指定要从哪个分支推送以及要推送到哪个分支:

git push origin localbranch:remotebranch

This could fail if the remotebranch is not an ancestor of the localbranch . 如果这种可能失败remotebranch不是的祖先localbranch If you use -f you can force an overwrite, but be careful, because this will lose commits. 如果使用-f ,则可以强制覆盖,但是要小心,因为这会丢失提交。

But you probably want to just merge the two locally, and push this updated master. 但是您可能只想在本地合并两者,然后推送此更新的母版。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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