How do I add/upgrade/downgrade a remote Git project in my repository without using submodules?

不想你离开。 提交于 2019-11-28 08:45:22

If all you want to do is frequently pull a remote's files into your project, and you don't care about connecting its history to yours, then no merging is required whatsoever.

Ultimately, the solution is dead simple:

  • Remove the old version of WordPress from the Git index;
  • Pull the new version of WordPress into the Git index with read-tree;
  • Commit.

read-tree is the only tool you need here, and since read-tree (smartly) refuses to overwrite files, you just need to remove the old tree from the index before reading the new one into its place.

$ git rm -r webroot/wordpress
rm 'webroot/wordpress/index.php'
rm 'webroot/wordpress/license.txt'
rm 'webroot/wordpress/readme.html'
...
$ git read-tree --prefix=webroot/wordpress/ -u wordpress/3.5.1
$ git commit -m "Updated to WordPress 3.5.1"
[master 9665ad7] Updated to WordPress 3.5.1
 44 files changed, 406 insertions(+), 176 deletions(-)
 rewrite webroot/wordpress/wp-admin/js/post.min.js (81%)
 rewrite webroot/wordpress/wp-includes/js/media-editor.min.js (99%)
 rewrite webroot/wordpress/wp-includes/js/media-views.min.js (89%)
...
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!