简体   繁体   中英

I Accidentally Pulled Master branch Of Repo1 Into local and changed Remote to Repo2 and pushed to specific Branch. How to Revert This?

I Had to -

  1. Clone Branch 2 from of repo 1.
  2. Change the Remote Origin of Local repo 2.
  3. Push Code to branch 1 of repo 2.

I Did -

  1. Clone Branch 1(master) from of repo 1.
  2. Change the Remote Origin of Local repo 2.
  3. Write Code.
  4. Push Code to branch 1 of repo 2.

I don't care if my code loses, I just Want to Re-do This Process without any branch conflicts

Perform these steps

  1. git log // then copy the commit id at which the state of your branch is correct .

  2. git reset --hard commitId

  3. git push -f

In case you don't want to lose the code:

  1. git log // then copy the commit id at which the state of your branch is correct .

  2. git reset --soft commitId

  3. git reset.

  4. git stash //saving the work
  5. git reset --hard //Erase everything
  6. git push -f

Now clone the correct repository and apply: git stash pop //this will bring in the changes on the intended repository

solve if there are any merge conflicts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM