[英]Tried to remove files from git, now branches are diverged and I can't push the changes
這是我第一次使用git(在bitbucket.org上,如果有區別的話),並且我向回購庫提交了一些音頻文件,但我顯然不想在那里。 我添加了然后將路徑添加到.gitignore,以發現這只會忽略進一步的更改。 所以我偶然發現了這個SO問題,並嘗試使用那里提到的David Underhill的腳本 。
但是,現在我收到git commit
的以下消息:
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 10 and 10 different commits each, respectively.
#
nothing to commit (working directory clean)
和git push
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://bitbucket.org/abc/def'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
所以我嘗試了一個git push --force
,成功了,但是實際上沒有改變倉庫中的任何東西,甚至沒有出現在倉庫中。
你知道我該怎么解決嗎?
git filter-branch
將重寫您的提交的SHA1的歷史記錄,因此錯誤消息很有意義。
如果您的本地存儲庫位於分支master上並且已刪除了這些文件,則git push -f
將在您的Bitbucket存儲庫上進行鏡像。
如果不是,那可能是因為您沒有首先推送本地主機(請確保嘗試git push -f origin master
)。
Ir,因為您(本地)處於分離頭模式 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.