Resolve merge conflicts: Force overwrite all files

后端 未结 2 978
野趣味
野趣味 2021-01-30 07:08

I am working on a git repository by myself (so yes, I know the implications and the warnings of doing this) and somehow one of the trees got a commit after being pushed

2条回答
  •  旧时难觅i
    2021-01-30 07:35

    git reset --hard {remote_repository_name}/{branch_name}
    

    Example:

    git reset --hard upstream/branch1
    

    If you are working with a branch you can use the above code.But before that, you have to set (upstream or origin) to your local repository,

    git remote add upstream https://github.com/lakini/example.git
    

    here,https://github.com/lakini/example.git is the remote upstream repository.

    Same as like this we can work in the remote repository(origin) as well.

    git reset --hard origin/branch1
    

提交回复
热议问题