Git add remote track branch6/30/2023 The next step is to filter the branches which remote branch is gone. Great! We now have a reliable, consistent way to retrieve our local branches and their remote tracking status. We can do one last optimization here, and that is to return the branches in their shortened format by using refname:short: $ git for-each-ref -format '%(refname:short) %(upstream:track)' refs/heads Now this is something we can work with! As we’re only interested in our local branches (heads), we’ll filter them by appending refs/heads to our command: $ git for-each-ref -format '%(refname) %(upstream:track)' refs/heads We can use git for-each-ref to list all branches and their upstream’s branch’s status in our desired format: $ git for-each-ref -format '%(refname) %(upstream:track)' It so happens that the git for-each-ref command lets us specify its output format, neatly circumventing the aforementioned problems.
0 Comments
Leave a Reply. |