git/list[1] front-page[2] threads[3] people[4] search[5] about
 

reflog: git rebase <upstream> <branch> vs git checkout <branch> && git rebase <upstream>

From
LELitvinenko, Evgeny <evlitvinenko@luxoft.com>
Date
Jan 26, 2018, 11:21 UTC
Message-ID
<B090F14416879147852DB59B4633393F01B4BFFCA2@DB-MBOX-07.dbdc.luxoft.com>
Hi Git community.
I have a question about reflog and "git-rebase(1) Manual Page".
As the man reads
------------------------- cut here -----------------------
git rebase [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]
            [<upstream> [<branch>]]

... If <branch> is specified, git rebase will perform an automatic git checkout <branch> before doing anything else. Otherwise it remains on the current branch. ------------------------- cut here -----------------------

So I think that
  git rebase master b1
is the same as
  git checkout b1 && git rebase master
but in the reflog I see that the 'git rebase master b1' does not write 'git checkout b1'
into the reflog.

The question is - why there is no records in the reflog about ' automatic git checkout <branch>'? Or maybe git's man page is not accurate about this step?

Here is my test: ------------------------- cut here ----------------------- mkdir git_rebase cd git_rebase/ git init echo "master 1" > file.txt git add file.txt git commit -m "master 1" git checkout -b "b1" echo "branch b1" > file_b1.txt git add file_b1.txt git commit -m "b1 1" git checkout master echo "master 2" >> file.txt cat file.txt git add file.txt git commit -m "master 2"

# make a copy of repo directory (tar -cf ../repo_dir.tar .) tar -cf ../git_rebase.tar .

# git rebase <upstream> <branch> git reflog git rebase master b1 git reflog

# restore the repo cd .. rm -Rf git_rebase mkdir git_rebase && cd git_rebase && tar -xf ../git_rebase.tar

# git checkout <branch> && git rebase <upstream> git reflog git checkout b1 && git rebase master git reflog ------------------------- cut here -----------------------

# In the case 'git rebase master b1' # 'git reflog' shows cac9cc7 (HEAD -> b1) HEAD@{0}: rebase finished: returning to refs/heads/b1 cac9cc7 (HEAD -> b1) HEAD@{1}: rebase: b1 1 29c7386 (master) HEAD@{2}: rebase: checkout master 29c7386 (master) HEAD@{3}: commit: master 2 5cb30a2 HEAD@{4}: checkout: moving from b1 to master e75c314 HEAD@{5}: commit: b1 1 5cb30a2 HEAD@{6}: checkout: moving from master to b1 5cb30a2 HEAD@{7}: commit (initial): master 1

# In the case ' git checkout b1 && git rebase master ' c08d270 (HEAD -> b1) HEAD@{0}: rebase finished: returning to refs/heads/b1 c08d270 (HEAD -> b1) HEAD@{1}: rebase: b1 1 29c7386 (master) HEAD@{2}: rebase: checkout master e75c314 HEAD@{3}: checkout: moving from master to b1 /* This line is absent in case of 'git rebase master b1' */ 29c7386 (master) HEAD@{4}: commit: master 2 5cb30a2 HEAD@{5}: checkout: moving from b1 to master e75c314 HEAD@{6}: commit: b1 1 5cb30a2 HEAD@{7}: checkout: moving from master to b1 5cb30a2 HEAD@{8}: commit (initial): master 1

Best regards and many thanks for your work. Evgeny.

________________________________
This 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.
Message 1 of 1 in “reflog: git rebase <upstream> <branch> vs git checkout <branch> && git rebase <upstream>”
  1. Litvinenko, EvgenyJan 26, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.