b/wa $ git pull 和 $ hg pull 的区别

发布于 2024-11-29 16:14:08 字数 617 浏览 0 评论 0 原文

Steve Losh:Mercurial 分支指南 -

Mercurial 默认会推/拉所有分支,而 git 只会推/拉当前分支。

我想知道我的理解是否正确:

我突然想到,当我执行 git pull 时,我实际上从除 < 之外的所有分支中执行 fetch 操作。 code>merge 仅发生在我所在的当前分支上。这非常接近mercurial,其中pull可以从远程获取所有内容;但还没有合并任何东西。

在 Mercurial 中,push 会发送所有内容,但需要显式的 update 才能将内容合并回来。我不太确定 push 操作的 git' 行为。

Steve Losh: A Guide to Branching in Mercurial -

Mercurial will push/pull all branches by default, while git will push/pull only the current branch.

I wonder if my understanding is right:

It occurs to me that when I do a git pull I actually do fetch from all branches but the merge happens only with the current branch that I am sitting on. This is very close to mercurial where a pull gets me everything from the remote; but does not merge anything yet.

In mercurial a push sends everything, but an explicit updateis needed to merge things back. I am not quite sure on git' behavior of the push operation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

影子的影子 2024-12-06 16:14:08

在 Git 中,你必须一一拉/推所有分支。因此,您可以在本地分支机构工作,而不会弄乱服务器。

您可以每次指定要拉取/推送的分支:git push origin master 表示您要将分支主控推送到原始分支,这通常是“默认”服务器。

In Git, you have to pull/push all the branches one by one. Thus, you can work on local branches without messing up the server.

You can specify each time which branch you want to pull/push on : git push origin master means you want to push your branch master on the one at origin, which is often the "default" server.

GRAY°灰色天空 2024-12-06 16:14:08

当 git pull 在没有任何 refspec 的情况下完成时会发生什么基于配置(来自 git-pull man 的默认行为部分):

为了确定要获取哪些远程分支(并可选择存储在远程跟踪分支)当在命令行上没有任何 refspec 参数的情况下运行该命令时,将查阅配置变量 remote..fetch 的值,如果没有任何值,则查阅 $GIT_DIR/remotes/ 文件及其拉:使用线。除了 OPTIONS 部分中描述的 refspec 格式之外,您还可以拥有如下所示的全局 refspec:

refs/heads/:refs/remotes/origin/

http://www.kernel.org/pub/software/scm/git/docs/git-pull.html

同样,git Push 推送的内容取决于在配置(和参数)上

无需额外配置,就像git push origin:一样。

当没有给出该命令时,可以通过设置远程的推送选项来配置该命令的默认行为。

例如,默认仅将当前分支推送到原始分支,请使用 git config remote.origin.push HEAD。任何有效的都可以配置为 git push origin 的默认值。

http://kernel.org/pub/software/scm/git /docs/git-push.html

What happens when git pull is done without any refspec is based on the config ( from the default behaviour section of git-pull man):

In order to determine what remote branches to fetch (and optionally store in the remote-tracking branches) when the command is run without any refspec parameters on the command line, values of the configuration variable remote..fetch are consulted, and if there aren’t any, $GIT_DIR/remotes/ file is consulted and its Pull: lines are used. In addition to the refspec formats described in the OPTIONS section, you can have a globbing refspec that looks like this:

refs/heads/:refs/remotes/origin/

http://www.kernel.org/pub/software/scm/git/docs/git-pull.html

Again what is pushed by git push depends on the configuration (and the paramaters)

Without additional configuration, works like git push origin :.

The default behavior of this command when no is given can be configured by setting the push option of the remote.

For example, to default to pushing only the current branch to origin use git config remote.origin.push HEAD. Any valid can be configured as the default for git push origin.

http://kernel.org/pub/software/scm/git/docs/git-push.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文