git merge 的 rebase 选项的目的是什么?

What is the purpose of git merge's rebase option?

here

学习git
git pull --rebase origin master

使用和不使用 --rebase 选项有什么区别?我读到 rebase 选项允许您在提交同步后将自己的提交放在 master 分支上,但这不是通常发生的事情吗?

我也不明白在结帐时指定分行作为选项的目的。

git checkout -b marys-feature master

为什么要指定master?如果您已经在 master 上,那么创建一个新分支不会自动使其成为 master 分支的副本。如果是这样,指定要复制的分支仅在您位于不想复制的分支(当前签出的分支)上时才有用,对吗?

此外,推送期间 -u 选项的用途是什么?

git push -u origin marys-feature

即使您没有 -u 它也会使它成为一个远程跟踪分支,对吧?我以为你推送的任何东西都会自动远程跟踪?

来自git pull doc

git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch. With --rebase, it runs git rebase instead of git merge.

来自 git checkout doc

Specifying -b causes a new branch to be created as if master was called and then checked out.

你的情况:git checkout -b marys-feature master
这意味着无论您在哪个分支上(无需提交任何更改),您都将创建一个名为 marys-feature 的新分支,其中包含来自分支的内容大师

关于你最后一个问题,你可以参考这个link:What exactly does the "u" do? "git push -u origin master" vs "git push origin master"

git push -u ...设置指定的上游跟踪分支。

意思是如果它还没有被跟踪,它就会被设置。如果分支被分配了上游跟踪分支,则更改为指定的分支(覆盖)。因此通常只需要在定义上游时应用一次。

Git默认推送,如果分支名称不同,则不会自动分配远程跟踪分支,有关push.default的详细信息,请参阅git-config documentation

Defines the action git push should take if no refspec is explicitly given. Different values are well-suited for specific workflows; for instance, in a purely central workflow (i.e. the fetch source is equal to the push destination), upstream is probably what you want. Possible values are:

nothing - do not push anything (error out) unless a refspec is explicitly given. This is primarily meant for people who want to avoid mistakes by always being explicit.

current - push the current branch to update a branch with the same name on the receiving end. Works in both central and non-central workflows.

upstream - push the current branch back to the branch whose changes are usually integrated into the current branch (which is called @{upstream}). This mode only makes sense if you are pushing to the same repository you would normally pull from (i.e. central workflow).

simple - in centralized workflow, work like upstream with an added safety to refuse to push if the upstream branch’s name is different from the local one.

When pushing to a remote that is different from the remote you normally pull from, work as current. This is the safest option and is suited for beginners.

This mode has become the default in Git 2.0.

matching - push all branches having the same name on both ends. This makes the repository you are pushing to remember the set of branches that will be pushed out (e.g. if you always push maint and master there and no other branches, the repository you push to will have these two branches, and your local maint and master will be pushed there).


git checkout -b marys-feature master

是运行

的快捷方式
git branch marys-feature master
git checkout marys-feature

这将创建一个名为 marys-featuremaster 的新分支,并将您的工作副本更改为 marys-feature

有关创建分支和更改工作副本的更多详细信息,请参阅官方 git-branch documentation