1

Initially, I mistakenly checkout the wrong branch of a project using git. I thought this was an easy fix, but I think I checked out the correct remote branch to new local branch. Oops. Now when I try to push my changes to the remote branch, git says I pushing a new remote branch, which is not what I would like.

How do I get my changed merged onto the correct remote/local branch so that I can commit/push to the correct remote branch?

I think I should rebase, but I want to ask the wisdom of the crowd before I break something else.

  • fetch the correct remote branch into the respective local branch. Then, move commits from your previous local branch into current branch – RomanPerekhrest Apr 15 '17 at 17:15

1 Answers1

0

You can always "copy" a commit from one branch to another, by doing cherry-pick.

Start with git fetch, to update your DB, then checkout the remote branch. You'll be seeing a snapshot of the remote branch, in detached mode.

Now do git cherry-pick [commit] (replace with commit ID), resolve any conflict if needed, then push.

Adashi
  • 461
  • 1
  • 4
  • 8