3 ms·
I prefer to think of rebase as accomplishing one simply-described task: Taking a series of commits from anywhere in the repo and replaying it starting from any
by dasil003 15y ago
I prefer to think of rebase as accomplishing one simply-described task:
Taking a series of commits from anywhere in the repo and replaying it starting from any point in the repo, possibly with modifications.
All the use cases described in the article and crazy CLI options fall out of this simple description. I realize there's quite a bit you need to grok before this becomes obvious, but nevertheless I think it's a good mantra to have as you are learning git and run into problems.
Eventually your mental model shifts from "what does this command option do?" to "what final state of the repository do I want?", and from there it's just a matter of practice.
- pagekalisedown 15y agoYou're description is correct, but it's also worth mentioning that the commit dates don't change when "replaying" them. In other words, the dates of commits won't be chronological after a rebase.
- lparry 15y agoThere are actually two dates associated with each commit. I cat recall the names for them off he top of my head but they're basically created_at and modified_at, and the modified_at ones will be chronological after a rebase.
- js2 15y agoEvery commit has both an author/author-date and a committer/committer-date. The former are retained during a rebase, the latter are reset. However, you can use --ignore-date to reset the author-date, or --committer-date-is-author-date to retain the original committer-date. In any case, when using git log, you can override its default of listing commits in reverse chronological order with --topo-order or --date-order.