如何抛出本地更改并从存储库克隆一个分支

时间:2020-04-28 18:18:54

标签: git pycharm

我不小心在分支“ develop”而不是“任务”分支进行了几次提交。现在,当我从development创建新分支时,我总是拥有这些先前的提交。因此,我需要从存储库中提取ALL开发分支,并需要丢弃所有本地更改和提交。 在没有完整克隆存储库到新文件夹的情况下该怎么办?

1 个答案:

答案 0 :(得分:2)

# on your develop branch
$ git checkout develop

# create the branch you want that should have the commits in develop
$ git branch task

# force the develop branch back to its original state
$ git reset --hard origin/develop

# switch to your task branch, and continue committing
$ git checkout task
相关问题