3 Replies - 415 Views - Last Post: 04 August 2013 - 09:59 AM Rate Topic: -----

#1 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2071
  • View blog
  • Posts: 4,307
  • Joined: 11-December 07

Gitting my branches all mixed up

Posted 30 July 2013 - 08:41 AM

I have a Git project that looks a bit like this:

                              master
                              |
A -> B -> C -> D -> E -> F -> G
      \
       H -> I
            |
            crazy-hack


The crazy-hack branch turned out to be just crazy enough to work. Normally I'd merge it into master and be happy. Unfortunately, somewhere between B and G something went horribly wrong. I'm worried if I merge, it'll end badly. I'd like to make my master branch point at I while keeping the old master branch somewhere. I'm not very experienced with git and this is important so if someone could have a look at the below I'd be grateful.

git checkout master
git branch old-master-2013-07-30
git reset --hard abc123 (where abc123 id the githash for B)/>
git merge crazy-hack
git branch -d crazy-hack


The aim is to make things look like this:

                              old-master-2013-07-30
                              |
A -> B -> C -> D -> E -> F -> G
      \
       H -> I
            |
            master        


Is This A Good Question/Topic? 0
  • +

Replies To: Gitting my branches all mixed up

#2 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2071
  • View blog
  • Posts: 4,307
  • Joined: 11-December 07

Re: Gitting my branches all mixed up

Posted 04 August 2013 - 05:05 AM

For anyone searching for answers to a similar problem, those steps seemed to work.
Was This Post Helpful? 1
  • +
  • -

#3 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5942
  • View blog
  • Posts: 12,870
  • Joined: 16-October 07

Re: Gitting my branches all mixed up

Posted 04 August 2013 - 09:20 AM

Thanks for the update.

I like git, but I try not to get too adventurous with my SCM. It's like messing with a partition table; unless you're extremely comfortable with it, the potential for disaster is high.

Of course, with git, you can just copy the entire directory and have it. But it's still worrisome.
Was This Post Helpful? 0
  • +
  • -

#4 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2071
  • View blog
  • Posts: 4,307
  • Joined: 11-December 07

Re: Gitting my branches all mixed up

Posted 04 August 2013 - 09:59 AM

I agree. I have only tried my recipe on a sadbox repo created especially for that purpose. I'll be making a backup of the real one before trying it there.

I watched a video with some advanced Git tricks. It was interesting but was peppered with comments urging care because a mistake might be permanent.

Addendum:

I suppose the distributed nature of Git adds some resilience. If we are working together and I screw up my repo, I can ask for a copy of yours. Even a single developer can make a backup or central repo somewhere, even on the same machine.

This post has been edited by cfoley: 04 August 2013 - 09:56 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1