Git notes

From I Will Fear No Evil
Revision as of 11:27, 30 March 2023 by Chubbard (talk | contribs)
Jump to navigation Jump to search

General git commands that are useful

Change git remote:

With or without ssh keys added to your user account..

git remote set-url origin git@gitlab01.iwillfearnoevil.com:monitoring/nmsui.git
or:
git remote set-url origin https://gitlab01.iwillfearnoevil.com/monitoring/nmsui.git

Sort git branches by last commit

git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'

Show git commit hashes for each branch sorted by date

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