Create git branch, and revert original to upstream state

前端 未结 3 1105
长发绾君心
长发绾君心 2020-12-23 10:12

I recently screwed up my git repo and would like to find out if there is any remedy to it.

My setup is this:

Central repo on github.
Personal repo on         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-23 10:51

    What exactly do you mean by

    I messed [up] my master and can no longer branch from it.

    You can always create a new branch from any commit in your repository, no matter how “messed up” it may be–which by the way is something Git has no notion of.

    Basically you can revert your repository to any state it previously had because Git will not explicitely delete any objects, it will only garbage collect unreferenced (dangling) objects every now and then. So you just need to find out what your repository looked like. gitk or git log can help you there.

    After you restored your local repository to a state you like you can simply push it back to your central public repository. If that results in a non-fast-forward push you might need to specify the --force flag when pushing.

提交回复
热议问题