问题描述
我的本地存储库名称位于此处:cd /Volumes/D/Website
我的Bitbucket存储库:https://[email protected]/Suprodeep/testlabs.git
当我尝试git push
时说:
supro@Homes-MacBook-Air Website % git push supro master
*To https://bitbucket.org/Suprodeep/testlabs.git
! [rejected] master -> master (fetch first)
error: Failed to push some refs to 'https://bitbucket.org/Suprodeep/testlabs.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g.,'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
supro@Homes-MacBook-Air Website %*
当我尝试先拉时:
git pull supro master --allow-unrelated-histories
*error: You have not concluded your merge (MERGE_HEAD exists).
hint: Please,commit your changes before merging.
fatal: Exiting because of unfinished merge.*
解决方法
听起来您有未合并的更改。尝试在回购和拉动中提交所有内容:
# Check what's not committed
git status
# Add everything if you have to,or individually depending on what you want
git add *
git commit
# Then pull
git pull supro master --allow-unrelated-histories
如果您不关心合并。您可以将其硬重置为HEAD
,然后拉
git reset --hard HEAD
git pull supro master --allow-unrelated-histories