我一直试图弄清楚如何使用Git执行以下操作:
所以我有一个带有git repo的网站文件夹并提交所有内容。我通常一直在下载Bootstrap作为ZIP并将其解压缩到我的仓库中。但是Bootstrap的GitHub有上游的变化,我认为这可能对我的项目有用。我想定期获取和合并他们的新版本的bootstrap,而不必每次重新下载并重新提交引导程序到我的仓库。
那么我如何在我的项目中使用Bootstrap的repo克隆(?)而没有来自Bootstrap的数百次提交使我的历史变得混乱,并且只是获取他们的上游更改?
非常感谢!
答案 0 :(得分:1)
您只需将Bootstrap回购添加为您自己回购的 submodule
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
例如参见博文:
它将显示为子文件夹,并将引用固定版本 如果需要,您还可以将其配置为always update to the latest commit of a given branch。
您的历史不会与Bootstrap回购历史混在一起 并且您的回购大小不会发生变化(它只包括gitlink entry,而不是所有回购)