如何获取远程GitHub存储库的上游更改?
问题描述:
我一直想弄清楚如何与Git做下列事情:如何获取远程GitHub存储库的上游更改?
所以我有一个网站文件夹与git仓库和提交和一切。我通常一直在下载Bootstrap作为ZIP并将其提取到我的回购库中。但Bootstrap的GitHub有上游的变化,我觉得可能对我的项目有所帮助。我希望定期获取并合并他们的新版bootstrap,而不必每次重新下载并重新提交bootstrap到我的repo时,都会有一个新的重大变化。
那么我该如何去引导Bootstrap的回购,在我的项目中克隆(?),而没有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
例如,参见博客文章的submodule:
- “Using Bootstrap as a git submodule”
- “Manage Twitter Bootstrap (How to Manage Twitter Bootstrap. The Sane Way.)”
- “Semi-automatically update customized Twitter Bootstrap within your project”
它将显示为子文件夹,并且会引用固定版本。
如果需要,也可以将其配置为always update to the latest commit of a given branch。
您的历史不会与Bootstrap回购历史记录混在一起。
而您的回购股票大小不会改变(它只包括一个gitlink entry,而不是所有回购)