How to undo 'git fetch'

前端 未结 4 1216
被撕碎了的回忆
被撕碎了的回忆 2020-12-30 21:25

I just added additional remote A to my repo B and then run git fetch A. How can I undo the fetch? If I just remove remote A

4条回答
  •  情书的邮戳
    2020-12-30 21:55

    You can delete whatever branches you accidentally fetched that you don't want to keep with the following command:

    git update-ref -d refs/remotes/YOUR_REMOTE_NAME/BRANCH_NAME_TO_DELETE

    To prevent them from getting fetched again, set your git remote to only fetch specified branches: git remote set-branches YOUR_REMOTE_NAME desired_branch1 [desired_branch2, desired_branch3, etc], e.g. git remote set-branches origin master.

    The default behaviour of set-branches is to always replace the list. If you want to append, use the --add option: git remote set-branches --add origin another_branch

提交回复
热议问题