Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


There are multiple ways, here are two

Let's assume that your tree looks like

* ---> /origin/master
|
* ---> commit A
|
* ---> commit B : HEAD

let's say that sha-A is the sha of commit A and sha-B is the sha1 of commit B

1/
You can swap the 2 commits with git-rebase -i

git rebase -i origin/master
then swap the 2 lines in the editor that pop-up and save.
that should rewrite the commits in the order B,A

at this point is it wise to rebase the whole things so that you can push

git pull -r

Now you want to save the corrent head:
git branch save HEAD

move master one up:
git reset --hard master HEAD^

now your  master is on B
you can push it
git push

and finally restore you master to A (the saved point)

git reset --hard save

we don't need the save branch anymore

git branch -d save

2/
you can play with branches and cherry pick to achieve the same


save our branch and our 2 commits
git branch save master

'rollback A and B on master'
git reset --hard origin/master

Now cherry pick B
git cherry-pick save

push it
git push

cherry pick A
git cherry-pick save^

now master is back to having both commit in reverse order and B  is pushed

we don't need the 'save' branch anymore

git branch -D save


Norbert

PS: you can do a gitk --all before all of the and keep it open, and
File/Update after each step to visualize what is happening...
Note that the second scenario can completely be done with gitk user interface

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.