git merge is totally find, while git rebase is something mysterious for me.
Right now, after yesterday's typical work I checked git status and found out that I'm in the process of rebasing. I used git rebase --abort and lost my changes.
Is it lack of discipline to learn this, or it's indeed more complicated than merge?
venting ended
All trouble arises when this abstraction breaks. It seems to me that the purpose of git merge is to simply allow you to work around broken abstractions. You can make the graph appear how you want, without having to jump through a bazillion unnecessary hoops to make a nice set of deltas.
Or... I'm wrong and about to find out after hitting "add comment"
There are a couple ways of performing a git rebase, namely
* git rebase
* git rebase interactive (git rebase -i)
* git rebase --onto
I think following these videos may help and will explain it better than I can.
What is Git Rebase? [Intermediate Git Tutorial] - https://www.youtube.com/watch?v=_UZEXUrj-Ds
Squashing Git commits with Interactive Rebase -https://www.youtube.com/watch?v=7IfkL8swmFw
How to undo git rebase using git reflog. - https://www.youtube.com/watch?v=qP4i3S2hujc&t=203s
My suggestion is: before every rebase:
- mkdir patches
- cd patches
- git format-patch HEAD~30 (in case you had 30 commits on top of the main branch but you can also "git format-patch $SHA" to get patches up to that SHA, not including)
- git pull --rebase
Then, if the rebase fails:
- git checkout -b branchname-rebaseattempt origin/branch
- make
- git am 0001*
- make
- git am 0002*
- git am --abort
- etc
This way you have a backup copy of every one of your commits as a patch file, and you can better understand and fix your conflict step-by-step without being "locked" in the process of a git-rebase. Sometimes when there are simple conflicts I edit the patch files themselves before applying.
If things don't really work and a conflict emerges you, as the master of time, have to decide the right data to put into the new timeline"
Hope it helps you breathe more easily :)