1

I got myself into a little bit of a local repo mess. Long story short, I had a copy of a remote repo; I created a branch called 'my_branch' in my local repo; I committed work a few times. I then just pushed the branch to the remote repo. Here's my local repo diagram...(since I've pushed my_branch to the remote, this is what remote looks like too).

--C0--------------C4--  (local master) 
      \
       --C1-C2-C3--     (local my_branch)

I then decided to try to rebase, but I think I totally messed up. I also tried to do git reset --hard and I think I corrupted my local repo some more. So I decided to start from a clean place. I grabbed my_branch from the remote repo following this.

I then checked out origin/my_branch from remote. (I now see that I have a "detached HEAD" in my GUI tool GitX.) Now...how do I merge this branch with origin/HEAD aka origin/master on remote?

Community
  • 1
  • 1
milesmeow
  • 3,688
  • 5
  • 35
  • 58

1 Answers1

1

Make a branch right where you are to get that work tracked

git checkout -b new-branch HEAD

Now you can check out other branches and merge or rebase them.

To get a local branch for a remote one that you are not tracking yet:

git checkout -t origin/some-branch

Now just push up the branches. Most likely you will require a force push

git push -f origin some-branch
Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
  • Just to see if I understand this...so for me I would do a `git checkout -t origin/my_branch` (this would checkout a local tracked version of my_branch. Then when I do a `git push -f origin my_branch` that would ask git to try to merge my_branch local and origin? – milesmeow Jan 10 '12 at 01:42
  • No. When you push, you are just changing a pointer to a particular commit. No merging occurs here. – Adam Dymitruk Jan 10 '12 at 19:28