{"thread":{"id":"47698","subject":"reflog: git rebase <upstream> <branch> vs git checkout <branch> && git rebase <upstream>","startedAt":"2018-01-26T11:21:54Z","lastAt":"2018-01-26T11:21:54Z","messageCount":1,"participants":["Litvinenko, Evgeny"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"337461","messageId":"B090F14416879147852DB59B4633393F01B4BFFCA2@DB-MBOX-07.dbdc.luxoft.com","threadId":"47698","inReplyTo":null,"subject":"reflog: git rebase <upstream> <branch> vs git checkout <branch> && git rebase <upstream>","fromName":"Litvinenko, Evgeny","fromEmail":"evlitvinenko@luxoft.com","sentAt":"2018-01-26T11:21:43Z","receivedAt":"2018-01-26T11:21:54Z","isPatch":false,"sender":{"key":"evlitvinenko@luxoft.com","avatar":null},"body":"Hi Git community.\n\nI have a question about reflog and \"git-rebase(1) Manual Page\".\nAs the man reads\n------------------------- cut here -----------------------\ngit rebase [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]\n            [<upstream> [<branch>]]\n\n...\nIf <branch> is specified, git rebase will perform an automatic git checkout <branch>\nbefore doing anything else. Otherwise it remains on the current branch.\n------------------------- cut here -----------------------\n\nSo I think that\n  git rebase master b1\nis the same as\n  git checkout b1 && git rebase master\nbut in the reflog I see that the 'git rebase master b1' does not write 'git checkout b1'\ninto the reflog.\n\nThe question is - why there is no records in the reflog about ' automatic git checkout <branch>'?\nOr maybe git's man page is not accurate about this step?\n\nHere is my test:\n------------------------- cut here -----------------------\nmkdir git_rebase\ncd git_rebase/\ngit init\necho \"master 1\" > file.txt\ngit add file.txt\ngit commit -m \"master 1\"\ngit checkout -b \"b1\"\necho \"branch b1\" > file_b1.txt\ngit add file_b1.txt\ngit commit -m \"b1 1\"\ngit checkout master\necho \"master 2\" >> file.txt\ncat file.txt\ngit add file.txt\ngit commit -m \"master 2\"\n\n# make a copy of repo directory (tar -cf ../repo_dir.tar .)\ntar -cf ../git_rebase.tar .\n\n# git rebase <upstream> <branch>\ngit reflog\ngit rebase master b1\ngit reflog\n\n# restore the repo\ncd ..\nrm -Rf git_rebase\nmkdir git_rebase && cd git_rebase && tar -xf ../git_rebase.tar\n\n# git checkout <branch> && git rebase <upstream>\ngit reflog\ngit checkout b1 && git rebase master\ngit reflog\n------------------------- cut here -----------------------\n\n# In the case 'git rebase master b1'\n# 'git reflog' shows\ncac9cc7 (HEAD -> b1) HEAD@{0}: rebase finished: returning to refs/heads/b1\ncac9cc7 (HEAD -> b1) HEAD@{1}: rebase: b1 1\n29c7386 (master) HEAD@{2}: rebase: checkout master\n29c7386 (master) HEAD@{3}: commit: master 2\n5cb30a2 HEAD@{4}: checkout: moving from b1 to master\ne75c314 HEAD@{5}: commit: b1 1\n5cb30a2 HEAD@{6}: checkout: moving from master to b1\n5cb30a2 HEAD@{7}: commit (initial): master 1\n\n# In the case ' git checkout b1 && git rebase master '\nc08d270 (HEAD -> b1) HEAD@{0}: rebase finished: returning to refs/heads/b1\nc08d270 (HEAD -> b1) HEAD@{1}: rebase: b1 1\n29c7386 (master) HEAD@{2}: rebase: checkout master\ne75c314 HEAD@{3}: checkout: moving from master to b1 /* This line is absent in case of 'git rebase master b1' */\n29c7386 (master) HEAD@{4}: commit: master 2\n5cb30a2 HEAD@{5}: checkout: moving from b1 to master\ne75c314 HEAD@{6}: commit: b1 1\n5cb30a2 HEAD@{7}: checkout: moving from master to b1\n5cb30a2 HEAD@{8}: commit (initial): master 1\n\n\nBest regards and many thanks for your work.\nEvgeny.\n\n________________________________\n\nThis e-mail and any attachment(s) are intended only for the recipient(s) named above and others who have been specifically authorized to receive them. They may contain confidential information. If you are not the intended recipient, please do not read this email or its attachment(s). Furthermore, you are hereby notified that any dissemination, distribution or copying of this e-mail and any attachment(s) is strictly prohibited. If you have received this e-mail in error, please immediately notify the sender by replying to this e-mail and then delete this e-mail and any attachment(s) or copies thereof from your system. Thank you.\n"}]}