Skip to main content

get_previous

Function get_previous 

Source
pub fn get_previous(repo: &Repository) -> Option<String>
Expand description

Returns the name of the previously checked-out branch (@{-1}), if any.

Walks the HEAD reflog looking for the most recent checkout/switch entry and extracts the source branch name from the message.

Returns None when there is no recorded previous branch (e.g. fresh clone) or the reflog cannot be read.