简体   繁体   English

如何在GIT中提取另一个存储库并更新到它的头部?

[英]How can I pull another repository and update to its head in GIT?

Here is the description of the problem in terms of Mercurial: 以下是关于Mercurial的问题描述:

Given: 鉴于:

  • Two repos A and B , where B is a fork of A 两个仓库AB ,其中BA的叉子
  • The current directory is a working directory for the tip of A . 当前目录是A尖端的工作目录。

Needed: 需要:

  • Pull in B and update to its most recent head REV . 拉入B并更新到最新的REV头。

This is what I want to do in term of Mercurial: 这就是我要用Mercurial要做的事情:

A> hg pull B
A> hg heads         # Notice the most recent head of B
A> hg update **REV**

How can I do it in GIT? 我该如何在GIT中做到这一点? More concretely: 更具体地说:

I know it should be trivial, still I cannot figure it out. 我知道这应该是微不足道的,但我仍然无法弄清楚。

Anyone? 任何人?

git remote add other_repo
git fetch
git merge other_repo/branch
git remote add a_repo a_repo_url
git fetch a_repo
git merge a_repo/branch

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将拉取请求从一个 Git 服务器迁移到另一个 Git 服务器以获取存储库? - How can I migrate the pull requests from one Git Server to another Git Server for a repository? 我可以仅从另一个git存储库中提取某些文件吗? - Can I pull only certain files from another git repository? 如何将另一个git存储库导入为子目录,其所有历史记录分组在提交日志的HEAD中? - How do I import another git repository as a sub-directory with all of its history grouped at the HEAD of the commit log? 如何从另一个git存储库中的子目录中提取对文件的更改 - How can I pull in changes to a file from a subdirectory in another git repository 如何从Git中的另一台计算机存储库中提取? - How do I pull from another computer's repository in Git? 可以使用git pull来通过上游更新存储库 - Can git pull be used to update repository with an upstream 如何在不下载整个存储库的情况下“拉”一个 git 数据库 - How can I "pull" a git database without downloading the whole repository 我如何从多个存储库执行git扩展拉 - How can I execute a git extension pull form many repository 如何在git中添加另一个存储库? - How can I add another repository in git? 如何回滚Git存储库及其远程服务器? - How can I roll back a Git repository and its remote?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM