How to show which Git branches have changed recently

I will admit to some bad working habits, one of them is working on multiple things at the same time rather trying to focus exclusively on one unit of work and completing it before I move on to the next thing. This means that I sometimes have multiple G…


This content originally appeared on DEV Community and was authored by Robert Rees

I will admit to some bad working habits, one of them is working on multiple things at the same time rather trying to focus exclusively on one unit of work and completing it before I move on to the next thing. This means that I sometimes have multiple Github branches that I'm working on for a repository. Unfortunately this intersects with another bad habit I have of not cleaning up my local branches frequently. The two combined mean that when I'm slicing between tasks I often find it difficult to find the branch I was working on before I switched tasks.

Enter Git sorts to save me!

By default Git sorts branches lexically but using the committerdate sort you instead get the branches from the most recently committed to the last commit date.

Git sorts can also be reversed by putting the minus sign before the sort name.

This effectively brings back the branches in the order you last changed them.

To summarise then:

git branch --sort=-committerdate

Allows you to see which branches you changed most recently in a repository.


This content originally appeared on DEV Community and was authored by Robert Rees


Print Share Comment Cite Upload Translate Updates
APA

Robert Rees | Sciencx (2021-08-30T10:19:29+00:00) How to show which Git branches have changed recently. Retrieved from https://www.scien.cx/2021/08/30/how-to-show-which-git-branches-have-changed-recently/

MLA
" » How to show which Git branches have changed recently." Robert Rees | Sciencx - Monday August 30, 2021, https://www.scien.cx/2021/08/30/how-to-show-which-git-branches-have-changed-recently/
HARVARD
Robert Rees | Sciencx Monday August 30, 2021 » How to show which Git branches have changed recently., viewed ,<https://www.scien.cx/2021/08/30/how-to-show-which-git-branches-have-changed-recently/>
VANCOUVER
Robert Rees | Sciencx - » How to show which Git branches have changed recently. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/08/30/how-to-show-which-git-branches-have-changed-recently/
CHICAGO
" » How to show which Git branches have changed recently." Robert Rees | Sciencx - Accessed . https://www.scien.cx/2021/08/30/how-to-show-which-git-branches-have-changed-recently/
IEEE
" » How to show which Git branches have changed recently." Robert Rees | Sciencx [Online]. Available: https://www.scien.cx/2021/08/30/how-to-show-which-git-branches-have-changed-recently/. [Accessed: ]
rf:citation
» How to show which Git branches have changed recently | Robert Rees | Sciencx | https://www.scien.cx/2021/08/30/how-to-show-which-git-branches-have-changed-recently/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.