1

I currently have a private repository on bitbucket which I use for developing my app on my laptop and desktop. On my laptop I started working on a new branch called bootstrap. I cloned it from origin/master. Unfortunately, I forgot to publish my local master first. Not realizing this, I then made 3 commits to the remote. This made the commits to origin/master and the remote does not have the bootstrap branch.

I then tried to push my local master commits, but it tells me I have the 3 incoming commits. I didn't realize all of this until I pulled on my desktop and everything is a mess. I have no idea how to proceed to fix this and I desperately need help.

merlot
  • 194
  • 3
  • 11

1 Answers1

0

everything is a mess

Then don't touch it.

  • Clone again your repo in another local repo: at least, everything will be reset.
  • add your first local repo as a remote to the second: git remote add first ../firstRepo
  • git fetch first

Then:

  • make your bootstrap branch in that new local repo: git checkout -b bootstrap
  • through a nice log: git log --oneline --graph -all --branches, seek your new commits in remotes/first, and cherry-pick them to your current bootstrap branch.
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for the quick response. I'm still a newb with git. I was thinking of just scrapping the bootstrap branch, completely removing the remote repository from bitbucket, then republishing the master from my laptop (which is the correct branch) back to bitbucket. Then I would pull that to my desktop after I deleted the old one. Would this work? – merlot Apr 06 '14 at 14:41
  • @merlot possibly, but do it in a separate clone. Don't touch your first one. – VonC Apr 06 '14 at 14:42
  • Ok, I created a clone of my local repo. However, it only contains the master branch (which is ok), but what if I need an un-merged branch? I suppose I could recreate it and manually copy changes from the old repo? – merlot Apr 06 '14 at 14:53
  • @merlot you fetch the old repo as I mention and you can then import the commit you want through cherry-picking. – VonC Apr 06 '14 at 14:54
  • Thanks for the help - back in business! – merlot Apr 06 '14 at 15:35