ingydotnet / git-subrepo

MIT License
3.18k stars 263 forks source link

Can't pull-make changes-push - #610

Closed MaurGi closed 4 days ago

MaurGi commented 5 months ago

I really don't understand how a normal workflow is supposed to work.

Assuming I just cloned it a subrepo in my ci/_lib folder-

I want to: 1 - Pull the latest changes from the subrepo remote master 2 - Make some local changes on top 3 - Push to the subrepo remote, possibly in another branch so I can create a PR on the upstream

I am doing:

$ git subrepo clean --ALL                          
$ git subrepo pull -v ci/_lib --force

without even adding any change, if I try to:

$ git subrepo push --branch=subrepo/ci/_lib ci/_lib
git-subrepo: There are new changes upstream, you need to pull first.

well darn, I just pulled...

MaurGi commented 5 months ago

note: the commit id in the subrepo file is the correct sha of master on the remote subrepo

MaurGi commented 5 months ago

anyone can help? my question is what is the sequence of commands to be able to pull the changes from subrepo remote master, make local changes, then push to another branch on remote so I can do a PR on the subrepo.

admorgan commented 5 months ago
git init .
touch "file1"
git add file1
git commit -m "Add file1"
git subrepo clone git@github.com:youruser/repo lib1
touch lib1/file2
git add lib1/file2
git commit -m "Add file2 to lib1"
git subrepo push -b "file2-in-lib1-branch" lib1

Heads up but you will be in a disconnected state. Because the SHA from the push won't be in the original branch, likely main or master, until your patch has been merged in subrepo will have trouble reconnecting the repos. This is because pushing to another branch doesn't change the branch that the subrepo is following you have to use --update for that. I have been debating, and recently decided to remove the commit that comes from pushing and just let everything sort itself out with the next pull.