Search code examples
gitgit-subtree

Is a git fetch necessary before git subtree pull?


I am in reference to the following article: git subtree blog entry.

Amongst other, the following commands are listed:

git remote add -f tpope-vim-surround https://bitbucket.org/vim-plugins-mirror/vim-surround.git
git subtree add --prefix .vim/bundle/tpope-vim-surround tpope-vim-surround master --squash
git fetch tpope-vim-surround master
git subtree pull --prefix .vim/bundle/tpope-vim-surround tpope-vim-surround master --squash

My question is:

what is the need for the git fetch tpope-vim-surround master?
Is it not redundant with the git pull listed next line below?


Solution

  • I believe it was fixed recently, but older versions of git subtree required a branch with the correct name to be present locally before it would fetch it remotely, or it would fail with "foo does not refer to a commit."

    So it's probably for compatibility with that.