Skip to main content
  1. Learn center
  2. Software Development
  3. Guides
  4. Git tutorial
  5. Git 协作
  6. 远程分支
  7. 获取远程分支
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

获取远程分支

只要没有冲突,在执行拉取时,来自远程分支的更改会自动合并到您当前的本地分支。如果您想获取远程的修改但又不想将它们合并到您当前的本地分支中,您可以执行 git fetch 命令

获取将从远程下载本地分支上尚不存在的更改。获取FETCH_HEAD ref 将跟踪从远程存储库中获取的更改。

当远程和本地分支都包含不同的后代时,修订历史记录将如下所示:

Diagram displaying revision history of branches with different mains.
远程和本地分支具有不同 main 时的修订历史记录。

更改获取后,您可以通过合并获取_HEAD 或执行拉取将这些更改应用到本地存储库。

Diagram displaying changes applied to local repo after mergeing.
合并后,更改将应用于本地存储库。

一旦获取FETCH_HEAD合并,修订历史记录将产生与git pull操作相同的结果。拉取是同时执行获取和合并操作。

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life