Skip to content

Add ability to switch to another subrepo branch (git subrepo clone -f) without repository url. #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
casnacaj opened this issue Jan 16, 2018 · 9 comments

Comments

@casnacaj
Copy link

Discussed in #328

User may be allowed to switch branch (or re-clone current branch) from the subrepo repository and throw all changes in project repository. Currently man may use git subrepo clone command but it requires to re-type subrepo url. There should be a possibility to reclone the branch withou the need to re-type the url - at least when git clone is used with '-f' switch. So the url may be optional or there should be another way to reclone branch.

@csitarichie
Copy link

This would be a nice feature

@bastianhjaeger
Copy link

Agreed. This is what bothers me right now.
Something like
git subrepo <path-to-sub> checkout <other-branch>
and
git subrepo <path-to-sub> checkout -b <new-branch>

Very important for me, too!

@grimmySwe
Copy link
Collaborator

There is a little "Catch 22" with the clone command. It uses the repo to guess the subdir and we would need the subdir to find the .gitrepo file :-) As the clone command runs without knowing which subrepo to interact with.

git subrepo checkout <path-to-sub> <other-branch> seems like it would be an ok solution with -b to create a new branch.

@alwaysharsha
Copy link

Is there a plan to fix this issue in future roadmap?

@flashdagger
Copy link

Hi. As an experiment I added subrepo reset (#489)
git subrepo reset <subdir> -b <branch>
This allows you to set the subrepo to a specific branch or even to a commit. Although it doesn't check if the commit resides on the branch....

@admorgan
Copy link
Collaborator

git subrepo pull -b will already let you select a branch/commit. I change branches all the time. The pull --force feature says it behaves the way you describe, but is currently broken. I am planning to fix the --force feature unless I can be convinced otherwise.

@flashdagger
Copy link

Thanks @admorgan for pointing it out. I didn't know subrepo pull could do the job.
When I want to switch to a commit do I have to specify the full SHA or can I use a commit-ish reference?

@nmunozsi
Copy link

nmunozsi commented Sep 8, 2020

Hi @admorgan, is the --force option working? I try to change branches using the pull but I get the error.

git-subrepo: Local repository does not contain 148426efe0d6b1b0c19976dcfe6e80bc59dcaf01. Try to 'git subrepo fetch module' or add the '-F' flag to always fetch the latest content.

How can I change branches without cloning?

Thanks!

admorgan added a commit to admorgan/git-subrepo that referenced this issue Sep 11, 2020
The documentation described how --force should work in pull, but
it was not implemented. This caused subrepo to display error
messages that did not work when changing branches that deviated
and an ancestory could not be cleaning tracked.

Fix ingydotnet#336
admorgan added a commit that referenced this issue Oct 29, 2020
The documentation described how --force should work in pull, but
it was not implemented. This caused subrepo to display error
messages that did not work when changing branches that deviated
and an ancestory could not be cleaning tracked.

Fix #336
@Freubert
Copy link

@nmunozsi For me this was caused by the fact that my subrepo branch was some commits behind master, but the updated master was already pulled into my subrepo folder. To solve this I just rebased my branch in the original repo and after that I was able to pull (even without --force) the branch into my subrepo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants