0

I'm working with a project in a directory called lucy with a Git subtree called lucy-web (cf. 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

I have two (relevant) remotes, origin and 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)

On origin, there is also a branch called staging:

(venv) Kurts-MacBook-Pro-2:lucy kurtpeek$ git status
On branch staging
Your branch is up to date with 'origin/staging'.

In the lucy-web subtree, I'd like to push the contents of origin/staging to the master branch on the staging remote. Usually, I do that with this command, which is now yielding an error:

(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.

It seems to me that what I need to do is merge the master branch on the staging remote into origin/staging before I can push, is that correct? If so, with what command can I do this?

Kurt Peek
  • 52,165
  • 91
  • 301
  • 526

1 Answers1

1
git fetch staging master:master
git merge master
phd
  • 82,685
  • 13
  • 120
  • 165