尝试使用git子树来跨多个项目共享公用库文件。这是我遇到的问题。Git子树推动总是失败
1)添加子树,使我的项目的“lib”子目录来自lib-dk存储库。
$ git subtree add --prefix=lib --squash [email protected]:dwknight/lib-dk.git master
2)请在 “LIB” 文件的更改
3)更改提交到主要的项目回购
$ git commit -am "update project"
4)将更新推入主体工程回购
$ git push origin master
5)将“lib”中的更改推回“lib-dk”回购
$ git subtree push --prefix=lib [email protected]:dwknight/lib-dk.git master
git push using: [email protected]:dwknight/lib-dk.git master
To [email protected]:dwknight/lib-dk.git
! [rejected] f455c24a79447c6e3fe1690f5709357b7f96828a -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:dwknight/lib-dk.git'
hint: Updates were rejected because the tip of your current branch is behind its remote counterpart. Merge the remote changes (e.g. 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
6)即使在lib-dk回购中没有任何变化,我也会得到这种拒绝。当我尝试拉动时,它表现得像是有些东西,但我可以通过拉动进行更新。仍然推继续被拒绝。
我没有使用'subtree'命令的经验,但'--squash'操作看起来像一个'rebase'选项。它有什么作用?如果它以某种方式修改分支历史记录,那么可能会导致此问题。 – asm 2013-02-11 16:22:15