`git pull` 是否仅将更改合并到签出的分支中?
Does `git pull` only merge the changes into the branch one is checked out into?
我最近在 git 中执行了以下操作:
git checkout a
git pull
(这下载了一些在另一个 b运行ch b
中添加的新代码)
git merge master
git checkout master
- 此时我希望
master
包含在 2) 中下载的更改,但它们不存在。我再次 运行 git pull
获取更改。
是否 git pull
仅获取更改并将更改合并到当前 b运行ch(我已检出)?如果是,是否有 git 命令将下载的更改合并到 every/specific b运行ches?
Does git pull fetch and merge the changes only into the current branch (which I'm checked out into)?
是的。
If yes, is there a git command to merge the downloaded changed into every/specific branches?
没有,没有。
你可以做的一件事(或多或少实用,取决于你的具体设置)是为稳定的别名制作一个自制的别名,但功能分支仍然需要在需要时单独更新。
假设 dev
和 master
分支稳定的示例
git config --global alias.upd8 '!git stash && git checkout master && git pull && git checkout dev && git pull'
然后当你需要更新稳定的本地分支时,只需
git upd8
(由于命令与 &&
链接,bash 仅在未返回错误代码时才会继续,因此它不会继续,例如当前情况不是 "stashable" 或者其中一个合并有问题。)
Does git pull fetch and merge the changes only into the current branch (which I'm checked out into)?
-- 是的。可以将 --all 选项与 git pull 命令一起使用,但那样只会更新所有分支的信息。它不会 拉取 所有分支上的代码。
If yes, is there a git command to merge the downloaded changed into every/specific branches?
-- 不。要将代码 拉入 到特定分支,您需要显式 checkout 分支,然后使用git 拉 命令。
纯粹git
Git的documentation说的很清楚
Incorporates changes from a remote repository into the current branch. In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD.
More precisely, 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.
您可以使用 --all 获取所有遥控器。
--all
Fetch all remotes.
请注意它是 'Fetch',而不是 'Pull'、'merge' 或 'integrate'。
hub 的 hub-sync
您可以尝试使用 GitHub 的 hub。
它的 hub-sync 命令同步本地分支。
Fetch git objects from upstream and update local branches.
Synopsis
hub sync [--color]
- If the local branch is outdated, fast-forward it;
- If the local branch contains unpushed work, warn about it;
- If the branch seems merged and its upstream branch was deleted, delete it.
If a local branch does not have any upstream configuration, but has a same-named branch on the remote, treat that as its upstream branch.
我最近在 git 中执行了以下操作:
git checkout a
git pull
(这下载了一些在另一个 b运行chb
中添加的新代码)git merge master
git checkout master
- 此时我希望
master
包含在 2) 中下载的更改,但它们不存在。我再次 运行git pull
获取更改。
是否 git pull
仅获取更改并将更改合并到当前 b运行ch(我已检出)?如果是,是否有 git 命令将下载的更改合并到 every/specific b运行ches?
Does git pull fetch and merge the changes only into the current branch (which I'm checked out into)?
是的。
If yes, is there a git command to merge the downloaded changed into every/specific branches?
没有,没有。
你可以做的一件事(或多或少实用,取决于你的具体设置)是为稳定的别名制作一个自制的别名,但功能分支仍然需要在需要时单独更新。
假设 dev
和 master
分支稳定的示例
git config --global alias.upd8 '!git stash && git checkout master && git pull && git checkout dev && git pull'
然后当你需要更新稳定的本地分支时,只需
git upd8
(由于命令与 &&
链接,bash 仅在未返回错误代码时才会继续,因此它不会继续,例如当前情况不是 "stashable" 或者其中一个合并有问题。)
Does git pull fetch and merge the changes only into the current branch (which I'm checked out into)?
-- 是的。可以将 --all 选项与 git pull 命令一起使用,但那样只会更新所有分支的信息。它不会 拉取 所有分支上的代码。
If yes, is there a git command to merge the downloaded changed into every/specific branches?
-- 不。要将代码 拉入 到特定分支,您需要显式 checkout 分支,然后使用git 拉 命令。
纯粹git
Git的documentation说的很清楚
Incorporates changes from a remote repository into the current branch. In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD.
More precisely, 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.
您可以使用 --all 获取所有遥控器。
--all
Fetch all remotes.
请注意它是 'Fetch',而不是 'Pull'、'merge' 或 'integrate'。
hub 的 hub-sync
您可以尝试使用 GitHub 的 hub。 它的 hub-sync 命令同步本地分支。
Fetch git objects from upstream and update local branches. Synopsis
hub sync [--color]
- If the local branch is outdated, fast-forward it;
- If the local branch contains unpushed work, warn about it;
- If the branch seems merged and its upstream branch was deleted, delete it.
If a local branch does not have any upstream configuration, but has a same-named branch on the remote, treat that as its upstream branch.