Reputation: 6044
I'm struggeling with branches in Git and fail to attribute them properly to commits. The newest two commits ended up in different branches (one in master, one in pm/gitrev) - but need them both to be on top of eachother in the same feature-branch (e.g. something new, like pm/git-version) which I can push to the remote repositor 'pm' so that I can create on GitHub a proper pull-request for origin/master.
My currently history is completely linear and looks like:
$ git log --graph --pretty=format:"%h %d %s %n" -4
* 02f82ee (HEAD -> git-version, pm/gitrev) Fail gracefully when operating on detached head
|
* 998d969 (pm/master, master) Change: Adopt the versioning scheme now with git
|
* c95db24 (origin/master, origin/HEAD) Added tag 0.4.5 for changeset e115586dd0a0
|
* 3418735 (tag: 0.4.5) Update: Changelog for release
I created a new branch, based on 998d969 (master) and rebased the other two onto it, e.g. by git rebase -b master git-version
. Yet my history is linear, but commits didn't change their branch as assume they should.
What do I miss with git rebase
? How do I remove all branch info from the top most commits and move them to their joint, but new branch, based on origin/master?
I can re-write history of the remote repo 'pm'.
Upvotes: 1
Views: 407
Reputation: 463
To move commits to a other branch you can use the command git cherry-pick
:
git cherry-pick <commit-hash>
You can get the commit-hash in the log of the original commit branch:
git log
Upvotes: 4