ingydotnet / git-subrepo

MIT License
3.22k stars 265 forks source link

`git subrepo pull/branch` fails after force-pushing to remote #541

Open nyanpasu64 opened 3 years ago

nyanpasu64 commented 3 years ago

After I rewrite and force-push to a remote, I can no longer git subrepo pull --method rebase to rebase my local branch on the new remote branch.

> git subrepo pull --method rebase 3rdparty/rtaudio
git-subrepo: Local repository does not contain 72d703e77db60c9faf31a5b78ddb272d08401065. Try to 'git subrepo fetch 3rdparty/rtaudio' or add the '-F' flag to always fetch the latest content.
> git subrepo branch 3rdparty/rtaudio/
git-subrepo: Local repository does not contain 72d703e77db60c9faf31a5b78ddb272d08401065. Try to 'git subrepo fetch 3rdparty/rtaudio' or add the '-F' flag to always fetch the latest content.

72d703e77db60c9faf31a5b78ddb272d08401065 is the latest remote commit seen from a prior fetch/pull. However I have rebased the rtaudio repository on upstream and force-pushed to the remote, removing 72d703e from the master branch. Now git subrepo pull fails, even though a regular git pull --rebase is perfectly capable of rebasing onto a force-pushed remote.

git subrepo pull --force [--method rebase] 3rdparty/rtaudio works (--method rebase is ignored), but discards all changes I made locally but haven't run git subrepo push on. If I've made the changes recently and haven't pushed them to master, I have to checkout a commit from before the changes, then cherry-pick the commits after running git subrepo pull --force. If I've already pushed the commits and don't want to force-push my local repo, git subrepo pull --force forces me to lose the changes in the process (I can try to reapply them afterwards).

Currently using git subrepo 0.4.3 (latest release, basically latest commit).

nyanpasu64 commented 3 years ago

I tried "checkout a commit from before the changes, then cherry-pick the commits after running git subrepo pull --force". I can't push the commits.

Screenshot_20210730_192915


nyanpasu64@ryzen ~/code/exotracker-cpp (fix-rtaudio-pipewire)> git subrepo fetch 3rdparty/rtaudio
git-subrepo: There is already a worktree with branch subrepo/3rdparty/rtaudio.
Use the --force flag to override this check or perform a subrepo clean
to remove the worktree.
nyanpasu64@ryzen ~/code/exotracker-cpp (fix-rtaudio-pipewire) [1]> git subrepo fetch --force 3rdparty/rtaudio

git-subrepo: Invalid option '--force' for 'fetch'.

turns out you need to git subrepo clean 3rdparty/rtaudio, git subrepo fetch 3rdparty/rtaudio, then you can push.


  The `push` command accepts the `--all`, `--branch=`, `--dry-run`, `--force`,
  `--merge`, `--rebase`, `--remote=`, `--squash` and `--update` options.

and if you try --rebase or --dry-run it doesn't work