1

Local repository A(branch feature/2.0 on A) in my system, i did git remote add associated with a remote repository B (branch main)
git add remote repository B
and then nothing changed, direct git push -f push local repository A to the remote associated repository B, now the associated remote repository B is overwritten by the local repository A content
git push -f global main
how to restore the content of the associated remote repository B,i have executed
git reflog --oneline
git reset --hard <commit-hash>
git push -f origin main
and repository B content is still overwritten by repository A,i want to restore repository B

Gmrakari
  • 11
  • 4
  • Which repos are associated with the remotes `global` and `origin`? – William Pursell May 13 '22 at 16:08
  • Not yet,My repo A associated with the remotess `global` – Gmrakari May 14 '22 at 01:23
  • i try `git reflog show remotes/origin/main` and it shows `25e8c88 (origin/main, origin/HEAD, global/main, main) remotes/origin/main@{0}: update by push` and `5e364c6 (HEAD -> feature/2.0) remotes/origin/main@{1}: pull: fast-forward` – Gmrakari May 14 '22 at 01:23
  • and then i try to executed `git reset --hard remotes/origin/main@{1}` and `git push -f global main` but it doesn't work and return "Everything up-to-date". – Gmrakari May 14 '22 at 01:26

1 Answers1

0

i went back to my old local repo B and try git push -f then it works.it will force update local to remote origin main

Gmrakari
  • 11
  • 4