强制我的本地主人成为起源/主人 [英] Force my local master to be origin/master

查看:76
本文介绍了强制我的本地主人成为起源/主人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我让主人和出身/主人陷入了旁观,并且不再对那个分支上的更改感兴趣。



我按照这些说明操作让我的本地主人指向正确的地方
让当前git branch master branch

  git checkout better_branch 
git merge --strategy =我们的master#keep这个分支的内容,但记录一个合并
git checkout master
git merge better_branch#快速转发master到合并

哪些工作正常,除了git status给出

  C:\data\ localprojects\\Beko2011Azure [master]> git status 

#分支主
#你的分支和'origin / master'分别有
#,并且分别有395和2个不同的提交。
$
没有提交,工作目录干净

所以我现在怎么样说服origin / master(github)来反映我的主人。

解决方案

如果要 origin / master master 相同:
$ b

  git push -f原产主:master 

讨论参数:


  • -f 强制标志。通常,在允许推送到分支之前正在应用一些检查。 -f 标志会关闭所有检查。

  • c $ c>是远程推送的名称(在一个仓库中可以有多个远程仓库)
  • master:master 表示:将我的本地分支 master 推送到远程分支 master 。一般形式是 localbranch:remotebranch 。当你想删除远程分支时,知道这一点特别方便:在这种情况下,你将一个空的本地分支推送到远程,从而删除它: git push origin:remote_branch_to_be_deleted 可以通过 p>




    相反方向:如果您想要抛弃 master 并且希望它与 origin / master 完全相同:

      git checkout master 
    git reset --hard origin / master


    I've let master and origin/master get stuck in the sidelines, and am no longer interested in the changes on that branch.

    I followed these instructions to get my local master pointing to the right place Make the current git branch a master branch

     git checkout better_branch
     git merge --strategy=ours master    # keep the content of this branch, but record a merge
     git checkout master
     git merge better_branch             # fast-forward master up to the merge
    

    which worked fine except git status gives

    C:\data\localprojects\Beko2011Azure [master]> git status
    
    # On branch master
    # Your branch and 'origin/master' have diverged,
    # and have 395 and 2 different commits each, respectively.
    #
    nothing to commit, working directory clean
    

    so how do I now persuade origin/master (github) to reflect my master. Anything orphaned on origin/master can be safely abandoned.

    解决方案

    To have origin/master the same as master:

    git push -f origin master:master
    

    Discussion on the parameters:

    • -f is the force flag. Normally, some checks are being applied before it's allowed to push to a branch. The -f flag turns off all checks.

    • origin is the name of the remote where to push (you could have several remotes in one repo)

    • master:master means: push my local branch master to the remote branch master. The general form is localbranch:remotebranch. Knowing this is especially handy when you want to delete a branch on the remote: in that case, you push an empty local branch to the remote, thus deleting it: git push origin :remote_branch_to_be_deleted

    A more elaborate description of the parameters could be found with man git-push


    Opposite direction: If you want to throw away all your changes on master and want to have it exactly the same as origin/master:

    git checkout master
    git reset --hard origin/master
    

    这篇关于强制我的本地主人成为起源/主人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆