Kgn-web
Kgn-web

Reputation: 7555

how to cherry pick commits while push to the same branch

I have following commit ids in git log against my some feature branch.(feature/navigation)

git log --pretty=oneline

8fc7aeb 
7b7809e
20d9bb2
7f302cb
9f0a3b5
fad0df5
011886a

If it was one commit the following command will do.

git push origin 7b7809e:feature/navigation

But here I am in need to push 4 commits which are not in order.

the commits that I need to pick from the above list are:-

#1 8fc7aeb
#2 7b7809e
#4 7f302cb
#6 fad0df5

How can I do this?? (Pushing commits on the same branch i.e., feature/navigation)

Thanks.

Upvotes: 2

Views: 227

Answers (1)

Arkadiusz Drabczyk
Arkadiusz Drabczyk

Reputation: 12393

A possible solution would be to rename current branch to something else, for example:

git branch -m feature/navigation feature/navigation.bak

Then re-create a new branch called feature/navigation from your stable branch, then manually cherry-pick commits from feature/navigation.bak you are interested in and push feature/navigation normally:

git push -u origin feature/navigation

Creating branches in git is very cheap.

Upvotes: 3

Related Questions