[Libreoffice] Newbie question: git push

Norbert Thiebaud nthiebaud at gmail.com
Sun Jan 8 10:06:32 PST 2012


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


More information about the LibreOffice mailing list