Git: Subtree Merge into a Deeply Nested Subdirectory?

前端 未结 2 643
太阳男子
太阳男子 2021-02-07 04:33

I\'m attempting to use git\'s subtree merge stategy where the subdirectory into which I want to merge is nested fairly deeply - currently four levels deep.

I followed th

2条回答
  •  伪装坚强ぢ
    2021-02-07 05:12

    Clarifying for future readers, the solution is in the comments of Chris Johnsen's response. If you're seeing the "fatal: entry not found in tree" error, get rid of the trailing slash at the end of your subtree prefix.

    For example, if you are trying to pull a GitHub Pages subtree with a command like

    git subtree --prefix gh-pages/ pull origin gh-pages
    

    and there are conflicts you will get an error like

     * branch            gh-pages   -> FETCH_HEAD
    fatal: entry  not found in tree 6e69aa201cad3e5888f1d12af0d910f8a10a8ec3
    

    Just remove the trailing slash from the gh-pages directory

    git subtree --prefix gh-pages pull origin gh-pages
    

    This will work, and will try to merge. The worst scenario you can get is when the auto merge fails and you get an error like

    Automatic merge failed; fix conflicts and then commit the result.
    

    but you just have to resolve the conflicts manually and you are done.

提交回复
热议问题