Search code examples
gitgit-subtree

Why am I told that "'master' does not refer to a commit" when I use git-subtree?


When I enter > git subtree add --prefix=<some dir> --squash <some repo> master I receive the message 'master' does not refer to a commit. If I change 'master' to a sha I still get a warning. The repo is valid and master exists in the repo that I am trying to pull in.


Solution

  • I eventually found this commit and the important bit of information is

    This patch:

    • relaxes the check the argument in "git subtree add " (previous code would not accept a ref name that does not exist locally too, new code only ensures that the ref is well formatted)

    My problem was that my local repo does not have a branch named master (semantic versioning). The simple workaround was to create a local branch named master (or whatever the name of the branch that you are trying to pull from is. That resolves the issue seen here: Adding git subtree from a branch Geoff Ryan could have created a local branch named cow and successfully used subtree)

    This should hopefully be resolved by git 1.9 but, for anyone using an earlier version, I hope that this saves you some frustration.