Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 373
griotspeak Avatar asked Feb 01 '14 16:02

griotspeak


People also ask

What is git subtree?

git subtree lets you nest one repository inside another as a sub-directory. It is one of several ways Git projects can manage project dependencies. Why you may want to consider git subtree. Management of a simple workflow is easy.

What does commit mean Gitlab?

Git commits are one of the key parts of a Git repository, and more so, the commit message is a life log for the repository. As the project/repository evolves over time (new features getting added, bugs being fixed, architecture being refactored), commit messages are the place where one can see what was changed and how.


1 Answers

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.

like image 89
griotspeak Avatar answered Sep 26 '22 17:09

griotspeak