![]() Skim the full summary in your text editor. I've trimmed the summary to just theĭetails relevant to this part of the rebase guide, but feel free to This is the rebase plan, and by editing this file you can instruct # f, fixup = like "squash", but discard this commit's log message Pick 8d3fc77 Add greeting.txt pick 2a73a77 Add farewell.txt pick 0b9d0bb fixup greeting.txt # Rebase f5f19fb.0b9d0bb onto f5f19fb (3 commands) Last three commits this way, so we'll run git rebase -i Introduce a new tool: the interactive rebase. Use the new commit to "fixup" the last one. So now the files look correct, but our history could be better - let's Looks like greeting.txt is missing "world". Need to correct an older commit? Let's start by setting up our sandbox ![]() +++ b/greeting.txt -0,0 +1 +Hello world! Fixing up older commitsĪmending only works for the most recent commit. ![]() ![]() You can see the fixed commitĬommit f5f19fbf6d35b2db37dcac3a55289ff9602e4d00 ( HEAD -> master ) Save and quit your editor (you have a chance to change amend will squash the changes into the most gitĪdd's) all files that git already knows about, and Let's add a file to our sandbox - and make a mistake:įixing this mistake is pretty easy. That loses vital information and makes puzzling out why certain changes were made more difficult in the future.Let's start with something simple: fixing your most recent commit. Rebasing one on top of the other tells a lie: we worked on the site, and then we worked on the documentation, and then at some point (a point you'll have to find) and for some reason we worked on the site and documentation together. A history visualizer like gitk or GitX will show both orders simultaneously. You can look at them separately in topological order (8, 7, 6, 5, 3, 1, 4, 2) using git log -topo-order or you can look at them interleaved in date order (8, 7, 6, 5, 4, 3, 2, 1), the git log default. Merging them tells the correct story: the web site and docs were developed separately, but then come together into one unit. Those are just noise to anyone reading the code and commit history in the future.īut when you have two truly divergent histories, it's best to leave them as divergent histories. ![]() This is good for things like keeping feature branches up to date while they're being worked on, the bookkeeping and review is easier if you don't have a bunch of intermediate merge commits that do nothing but update the branch. Rebase turns parallel histories into linear histories, basically pretending that one set of changes was done on top of another set all along. The cases I have encountered a couple of times recently have been in moving a project's documentation from GitHub Wiki to GitHub Pages (when the website already exists). If that works at all, it's going to do something weird. Your command is equivalent to: git rebase -p -onto 3 5ĥ is a direct ancestor of 3, so that command doesn't make much sense. Part of the problem is HEAD~2 is a direct ancestor of origin/a-prime. uses the -interactive machinery internally, but combining it with the -interactive option explicitly is generally not a good idea unless you know what you are doing (see BUGS below).īut even without the -i it still fails with fatal: refusing to merge unrelated histories. The git-rebase docs say to not combine -i and -preserve-merges. Git rebase -preserve-merges -onto origin/a-prime HEAD~2 -i To reproduce checkout master then execute: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |