git pull,合并更改是工作树吗? [英] Git pull, merge changes is worktrees?

查看:196
本文介绍了git pull,合并更改是工作树吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 我从github克隆存储库
  • 我创建了几个工作树宽度:
 git worktree add -path- -branch-

当我从master的存储库中提取更改时,这个工作树也会更新吗?

When I pull changes from repository in master, this worktrees update too?

推荐答案

根据您用于拉动更改"的命令,答案是否"或不完全".

Depending on what commands you use to "pull changes", the answer is either "no' or "not exactly".

从远程获取更新的最简单方法是git fetch.这将更新数据库(通过从远程对象添加对象(如果它们尚未在本地存储库中添加)),并可能更新引用. (通常,它会更新特定于该远程服务器的远程跟踪参考.可以告诉它直接更新本地分支,但这并不是一个好主意.)无论如何,fetch不会执行合并;它要么不理会本地分支机构,要么更新它们以匹配远程服务器并破坏任何本地更改. (同样,默认值是不理会它们.)

The simplest way to get updates from the remote is git fetch. This updates the database (by adding objects from the remote if they weren't already in the local repo) and may update refs. (Usually it updates remote tracking refs specific to that remote. It can be told to directly update local branches, but this is rarely a good idea.) In any event, fetch does not perform merges; either it leaves the local branches alone, or it updates them to match the remote and clobbers any local changes. (Again, the default is to leave them alone.)

获取后,您可以cd进入工作树,在其中您已签出给定的本地分支,并且merge相应的远程跟踪引用进入该分支(或执行具有类似方法的变基).

Having fetched, you could then cd into the worktree where you have a given local branch checked out and merge the corresponding remote tracking ref into that branch (or do a rebase that has a similar approach).

git pull是先执行获取操作,然后进行合并操作的简写. (同样,这是默认设置.您可以更改配置,使其变为获取然后重新设置基础".)因此,如果您在工作树中已签出给定的分支,则可以可以执行git pull并且可以启动到该分支的合并(使用该工作树及其暂存区).

git pull is a shorthand for doing a fetch followed by a merge. (Well... again, that's the default. You can change the configuration so that it becomes "fetch and then do a rebase"...) So if you're in a worktree where you have a given branch checked out, you can do a git pull and that could initiate a merge into that branch (using that worktree and its staging area).

但是,如果您正在寻找一个将启动合并到所有工作树中的命令(这听起来像您的要求),则可能必须编写类似的脚本. (老实说,我不推荐这样的事情.)

But if you're looking for a single command that would initiate merges into all of the worktrees (which is kind of what it sounds like you're asking), you would have to probably script something like that. (And honestly, I don't recommend such a thing.)

这篇关于git pull,合并更改是工作树吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆