简体   繁体   English

git分支重新设置后分歧

[英]git branches diverged after rebase

I have followed this answer ( How to remove/delete a large file from commit history in Git repository? ) to get rid of some big, unwanted files in a repository. 我遵循了这个答案( 如何从Git存储库中的提交历史记录中删除/删除大文件? )来摆脱存储库中一些不需要的大文件。 I have done all the steps stated there in my local copy (because trying to do it in the bare, original, repository results in an error as long as it does not have a working tree). 我已经完成了本地副本中所述的所有步骤(因为尝试在裸露的原始存储库中执行操作会导致错误,只要它没有可用的树即可)。 Nevertheless, when I finish the steps (having removed the files, etc.) and I do a "git status" on my local copy, I get 但是,当我完成步骤(删除了文件等)并在本地副本上执行“ git status”时,我得到了

# On branch master
# Your branch and 'origin/master' have diverged,
# and have 16 and 18 different commit(s) each, respectively.

and I do not know how to send the changes back to the central repository. 而且我不知道如何将更改发送回中央存储库。 Can anybody help me? 有谁能够帮助我?

Since you have change the history of your commits, you would have to force push them back to origin: 由于更改了提交的历史记录,因此必须强制将其推回原点:

git push --force

This is dangerous and disruptive. 这是危险和破坏性的。 Make sure to communicate that event (before pushing) to anyone having already pulled from your repo: they will need to reset their master branch to the one you just pushed: 确保将该事件(在推送之前)传达给已经从您的仓库中撤出的任何人:他们将需要将其master分支重置为您刚刚推送的分支:

git checkout master
git fetch
git reset --hard origin/master

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

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