I have a subrepo in an ext/[subrep] directory that I want to track a different branch.
I have followed the instructions for switching subrepo branches at https://github.com/ingydotnet/git-subrepo/wiki/FAQ however, it does not seem to be working.
First, since the code in the subrepo and its parent are not production ready code, I want this subrepo to be on an independent branch.
For better reference tracking, I created a new branch, then merged all of the existing work from the previously tracked branch into the new branch.
If I follow the instructions explicitly, that is without specifying the exact directory where the subrepo is located, I get a new directory instead simply changing the branch reference in the .gitrepo file.
After having merged my existing work with the new branch, if I then specify the remote URL, the branch I want to track, and the existing directory, the clone simply tells me that the subrepo is up-to-date without changing anything - even with the --force flag specified.
What I have had to do is to
- git subrepo clean ext/[subrepodir]
- git rm -r -f ext/[subrepodir]
- physically delete ext/[subrepodir] (cloning the subrepo here without first deleting the directory gives the directory not empty error even with the --force flag.
- git commit
- git subrepo clone [remoteURL] ext/[subrepodir] --force -b new_branch
The result of the above is that the subrepo is properly tracking the new branch. However, from the FAQ it seems like I should not have to go through all of this just to switch the branch that the subrepo is tracking.
Is this a bug?
It looks like this is possible using the syntax:
I needed to first invoke (in at least some situations):
https://github.com/ingydotnet/git-subrepo/issues/336#issuecomment-663901849