How do I hide deleted "pr" branches?

I have GitHub for Windows. When I run "git branch -a" it shows many remote tracking branches and they appear to be pull requests.

One employee who uses Git for Windows cannot see this, but another employee who also uses GitHub for Windows sees the same result.

Example: I have unlocked "bootstrap-sass". On github.com I used the "Clone in desktop" button. It opens GitHub for Windows and adds a new repo to the list of local repositories.

Running "git branch -a", it returns over 100 results, most of them are "/ pr / #". Below is a small example:

C:\gh-ui\bootstrap-sass [master]> git branch -a
  bower
* master
  remotes/kenshub/2.0-stable
  remotes/kenshub/2.1-stable
  remotes/kenshub/HEAD -> kenshub/master
  remotes/kenshub/gh-pages
  remotes/kenshub/master
  remotes/kenshub/next
  remotes/origin/bower
  remotes/origin/master
  remotes/origin/pr/3
  remotes/origin/pr/4
  remotes/twbs/2.0-stable
  remotes/twbs/2.1-stable
  remotes/twbs/gh-pages
  remotes/twbs/master
  remotes/twbs/next
  remotes/twbs/pr/1
  remotes/twbs/pr/10
  remotes/twbs/pr/103

      

I assume this is GitHub for Windows. How do I hide deleted "pr" branches? Is this git config or part of the "Clone in desktop" command?

+3


source to share


3 answers


When cloning a repo, do not use the Clone on Desktop option if you have GitHub for Windows installed. Instead, copy the clone url and run git clone <url>

through the command line.

When you clone GitHub for Windows, it runs additional commands like:



fetch origin +refs/pull/*/head:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/* --prune
status --untracked-files=all --porcelain -z

      

If you don't want to re-clone the repo, refer to the other answer on deleting branches and make sure you don't have a refetch congif reference to get the "/ pr /" branches. Browse your file .git/config

or run git config --list --local

.

+1


source


You cannot hide, you can delete these remote tracking threads.
Following " Can you remove multiple branches in one command with Git? " You can try something similar to:

git branch -D `git for-each-ref --format="%(refname:short)" refs/remotes/*/pr/*`

      

(or you can use other expressions with awk and xargs )



It's like deleting one remote tracking branch .

But understand that this is a workaround: the following fetch, if configured by default fetch = +refs/heads/*:refs/remotes/origin/*

, will return all remotes branches.
As explained in " Git Internals - Refspec ", you can also set up multiple fetch to fetch only the remote tracking branches that you want to see.

0


source


It is also possible to manually edit the .git / config file and not track all upstream branches, but specific ones.

[remote "upstream"]
  url = https://github.com/xyz/xyz.git
  fetch = +refs/heads/*:refs/remotes/upstream/*

      

Replace '*' with a specific branch name

[remote "upstream"]
  url = https://github.com/rsocket/rsocket-java.git
  fetch = +refs/heads/1.0.x:refs/remotes/upstream/1.0.x

      

Then you need to delete remote tracking branches one by one

git branch -d -r upstream/0.2.x

      

Removing links - This does not remove remote branches, it just removes from local.

Batch pruning - removes remote branches

0


source







All Articles