git: How to move last N commits made to master, into own branch?
- by amn
Hi all,
I have a repository where I had been working on master branch having last committed some 10 or so commits which I now wish were in another branch, as they describe work that I now consider experimental (i am still learning good git practices). Basically I would like to have these last 10 commits starting from a point in master to form another branch instead, so that I can have my master in a release state (which is what I strive for.)
So, this is what I have (rightmost X is the last commit good for release):
b--b (feature B)
/
X--X--X--Z--Z--Z--Z--Z--Z (master)
\
a--a--a (feature A)
You can see that both X and Z are on master, while I want commits marked by Z (my feature Z work) to lie on their own feature branch, and so that rightmost X is at the tip of master forming a good master branch tip. I guess this is what I want:
b--b (feature B)
/
X--X--X (master)
\ \
\ Z--Z--Z--Z--Z--Z (feature Z - the branch I want Z on)
a--a--a (feature A)
That way I will have my master always ready for release, and merge A, B and Z features when the time comes.
Hope I am making sense here...