[Git]将remote branch强制更新到local branch

来源:互联网 发布:淘宝生意参谋是什么 编辑:程序博客网 时间:2024/06/05 17:03

问题描述

本地branch状态与远程branch状态不一致,并且有conflicts。此时如果想将本地branch更新同远程branch一样的状态,直接进行pull,会有很多conflicts。

解决方法

1. 尝试将本地分支回退到一个可以fast-forward的commit,然后进行pull操作。

git reset --hard {some_commit}

git pull origin {local_branch_name}

或者:

2. 从远程repository fetch,然后强制更新local branch.

git fetch --all

git reset --hard origin/{remote_branch_name}


原创粉丝点击