简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM