git branch order by date 1

git branch order by date

git for-each-ref --sort=-committerdate refs/heads/

# Or using git branch (since version 2.7.0)
git branch --sort=-committerdate  # DESC
git branch --sort=committerdate  # ASC

Here is what the above code is Doing:
1. git for-each-ref –sort=-committerdate refs/heads/
– This command lists all the branches in the repository, sorted by the date of the last commit on each branch.
– The –sort option takes a string that specifies the sort order.
– The -committerdate option sorts by the date of the last commit on each branch.
– The – in front of committerdate reverses the sort order, so that the most recent commits appear first.
– The refs/heads/ option tells git to list only the branches in the repository.
2. git branch –sort=-committerdate
– This command lists all the branches in the repository, sorted by the date of the last commit on each branch.
– The –sort option takes a string that specifies the sort order.
– The -committerdate option sorts by the date of the last commit on each branch.
– The – in front of committerdate reverses the sort order, so that the most recent commits appear first.

Similar Posts