简体   繁体   English

如何获取远程GitHub存储库的上游更改?

[英]How do I pull upstream changes of a remote GitHub repository?

I've been trying to figure out how to do the following with Git: 我一直在尝试找出如何使用Git执行以下操作:

So I have a website folder with a git repo and commits and everything. 因此,我有一个带有git repo的网站文件夹,并提交了所有内容。 I've usually been downloading Bootstrap as a ZIP and extracting it into my repo. 我通常一直以ZIP格式下载Bootstrap,并将其解压缩到我的仓库中。 But there's upstream changes on Bootstrap's GitHub that I feel might be useful to pull in my project. 但是在Bootstrap的GitHub上有上游更改,我认为引入我的项目可能有用。 I'd like to periodically fetch and merge their new version of bootstrap without having to re-download and re-commit bootstrap to my repo everytime there's a new big change. 我想定期获取并合并其新版本的Bootstrap,而不必每次有新的大变化时都重新下载Bootstrap并将其重新提交给我的仓库。

So how do I go along taking Bootstrap's repo, cloning (?) in my project without having the hundreds of commits from Bootstrap cluttering up my history, and JUST fetch their upsteam changes? 那么,如何在我的项目中进行Bootstrap的回购,克隆(?),而又不会让Bootstrap的数百次提交弄乱我的历史,而只是获取他们的最新变更?

Thanks so much! 非常感谢!

You can simply add the Bootstrap repo as a submodule of your own repo 您可以简单地将Bootstrap存储库添加为您自己存储库的子模块

git submodule add https://github.com/twitter/bootstrap.git
git add .gitmodules bootstrap
git commit -a -m "Added bootstrap submodule"
git submodule init
git submodule update

See for instance the blog posts: 例如,查看博客文章:

It will appear as a subfolder, and will reference a fixed version. 它会显示为子文件夹,并引用固定版本。
You can also configure it to always update to the latest commit of a given branch if you want. 如果需要,还可以将其配置为始终更新到给定分支的最新提交

Your history won't be mixed with Bootstrap repo history. 您的历史记录不会与Bootstrap回购历史记录混合在一起。
And your repo size won't change (it only includes a gitlink entry , not the all repo) 而且您的repo大小不会改变(它仅包含gitlink条目 ,而不是所有repo)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM