如果您只想将远程文件拉入项目中,并且不关心将其历史记录连接到您的项目,则无需任何合并。
最终,解决方案很简单:
read-tree
read-tree 是你需要的唯一工具,从那以后 read-tree (聪明地)拒绝覆盖文件,你只需要从索引中删除旧树,然后再将新树读到它的位置。
$ 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%) ...