How can I choose to overwrite remote repository with local commits?

后端 未结 4 1825
闹比i
闹比i 2020-12-25 10:42

Basically, due to events beyond my control, my remote repo was moved - I did a lot of work on my local copy in the meantime and now I really just want to overwrite everythin

4条回答
  •  太阳男子
    2020-12-25 11:12

    How to do this for master branch, without pulling data down from the remote repo:

    1. Create a new folder, init git, add remote repo - don't pull or fetch!

      mkdir clean_repo

      git init

      git remote add origin

    2. create (and switch to) empty local branch, add, commit and push a test file into this.

      git checkout test

      echo "test" > test

      git add .

      git commit -m "adding test"

      git push origin:test

    3. On github / bitbucket, change default branch to new branch

    4. On local, switch to master branch, commit and push to remote repo / branch

      git checkout -b master

      git push origin --mirror

提交回复
热议问题