Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: How to unfetch remote branches (Github pull requests)

I have ran

git fetch upstream +refs/pull/*:refs/remotes/upstream/pr/*
git fetch origin +refs/pull/*:refs/remotes/origin/pr/*

And I ended up with several hundreds of branches - 4 for each pull request (head, merge, and both from origin and upstream.

How can I get rid of these branches locally, in two steps?

I have tried

git branch -D refs/remotes/origin/pr/*

but that says "not found".

like image 979
Ondra Žižka Avatar asked Oct 01 '15 12:10

Ondra Žižka


People also ask

How do I fetch a particular remote branch?

If you have a single remote repository, then you can omit all arguments. just need to run git fetch , which will retrieve all branches and updates, and after that, run git checkout <branch> which will create a local copy of the branch because all branches are already loaded in your system.

How do I revert a git pull from another branch?

There is no command to explicitly undo the git pull command. The alternative is to use git reset, which reverts a repository back to a previous commit.


1 Answers

I usually just remove files from .git/refs and lines .git/packed-refs

like image 74
max630 Avatar answered Oct 05 '22 15:10

max630