tags:

views:

35

answers:

2

I am currently on my master branch. I need some help with CSS but unfortunately my site is protected by authentication. This makes it very difficult for others to come to my site to debug. I was planning to start a new branch, fixing_css, with the first commit removing all authentication mechanism.

Then I was thinking of commiting changes made to CSS. After that, I want to merge that branch back to the master except for the first commit (since I want my site to be protected by my authentication system).

How do I go about doing that?

+4  A: 

You could rebase the set of commits onto your master branch:

If you have this:

master: A--B--C--D
                  \
fixing_css:        E--F--G--H

And you want this:

master: A--B--C--D--F--G--H

Then run this command from the fixing_css branch:

git rebase --onto master E fixing_css

(where E is the SHA of that first commit on the branch)

The "rebase" command takes a set of commits and puts them onto a new "base". In this case, you're saying "take the set of commits that comes after E and goes up through the end of fixing_css, and put them on top of master".

Amber
+1  A: 

Apart from regular rebase, you can also use the interactive rebase to get rid of any changes you don't want:

git rebase -i master

It will spawn an editor listing all your commits. If you want to remove a commit simply delete the line in your editor before saving the file. This way you can remove as many commits as you need before merging.

slebetman