我正在一个名为lucy
的目录中使用名为lucy-web
的Git子树(参见How can I list the git subtrees on the root?)的项目:
(venv) Kurts-MacBook-Pro-2:lucy kurtpeek$ git log | grep git-subtree-dir | tr -d ' ' | cut -d ":" -f2 | sort | uniq
lucy-web
我有两个(相关)遥控器,origin
和staging
:
(venv) Kurts-MacBook-Pro-2:lucy kurtpeek$ git remote -v
origin https://github.com/startwithlucy/lucy.git (fetch)
origin https://github.com/startwithlucy/lucy.git (push)
staging https://git.heroku.com/lucy-staging.git (fetch)
staging https://git.heroku.com/lucy-staging.git (push)
在origin
上,还有一个名为staging
的分支:
(venv) Kurts-MacBook-Pro-2:lucy kurtpeek$ git status
On branch staging
Your branch is up to date with 'origin/staging'.
在lucy-web
子树中,我想将origin/staging
的内容推送到master
遥控器上的staging
分支。通常,我使用此命令执行此操作,该命令现在产生错误:
(venv) Kurts-MacBook-Pro-2:lucy kurtpeek$ git push staging `git subtree split --prefix lucy-web staging`:master
cache for 09dc1ce7e3b490f30ceeabbca0c9375e2013b596 already exists!
To https://git.heroku.com/lucy-staging.git
! [rejected] 07fb260ddaeee35ef1c798c97dbe5e35d882bdbe -> master (fetch first)
error: failed to push some refs to 'https://git.heroku.com/lucy-staging.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.
在我看来,我需要做的是将master
遥控器上的staging
分支合并到origin/staging
,然后再推,这是正确的吗?如果是这样,我可以使用什么命令执行此操作?
答案 0 :(得分:1)
git fetch staging master:master
git merge master