Reputation: 2400
I have a local branch in my sandbox repository called local-branch
which tracks a remote branch called remote-branch
. I created the local branch thus:
$ git checkout -b local-branch remotes/origin/remote-branch
I created a branch from the local-branch
called dev-branch
:
$ git checkout -b dev-branch local-branch
I then committed some changes to dev-branch
and now want to push it upstream to a branch off remote-branch
. There it gets reviewed, approved and then merged into remote-branch
. Following that, I need to git pull
on my local-branch
to sync it with remote-branch
.
I am trying the following but this does not seem to work.
$ git push remotes/origin/remote-branch local-branch
I see the following error:
fatal: 'remotes/origin/remote-branch' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
But I can see the repository when I run:
$ git branch -a
Upvotes: 2
Views: 3641
Reputation: 139691
To push local-branch
from your repository into remote-branch
on remote origin
, use
git push origin local-branch:remote-branch
Based on the way you created local-branch
in your question, git should have configured it to track origin/remote-branch
. In that case, a simple git pull
while local-branch
is checked out will suffice to sync.
Your workflow is complicated. I suggest looking for ways to simplify that involve fewer names for each given branch.
Upvotes: 4