Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grep Git Branch Names, Return Only Branches Whose Name Contain "Theme"

Tags:

If I have a list of 48 remote branches for a repo, I can do

git branch -a 

To list all of them, how do I grep through those to only return the ones whose name contains Theme?

like image 222
Joshua Soileau Avatar asked Sep 25 '15 13:09

Joshua Soileau


People also ask

How do you get specific branch from remote?

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 find fetched branches?

To view your remote branches, simply pass the -r flag to the git branch command. You can inspect remote branches with the usual git checkout and git log commands. If you approve the changes a remote branch contains, you can merge it into a local branch with a normal git merge .


1 Answers

Just use the pipe operator (|):

git branch -a | grep Theme 
like image 110
J.R. Owens Avatar answered Oct 19 '22 14:10

J.R. Owens