Git notes: Difference between revisions

From I Will Fear No Evil
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
=== General git commands that are useful ===
=== General git commands that are useful ===
Change git remote:
== Change git remote:==


With or without ssh keys added to your user account..
With or without ssh keys added to your user account..
Line 10: Line 10:
</pre>
</pre>


Sort git branches by last commit
== Sort git branches by last commit ==
<pre>
<pre>
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))'
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))'
</pre>
</pre>


Show git commit hashes for each branch sorted by date
== Show git commit hashes for each branch sorted by date ==
<pre>
<pre>
git for-each-ref --sort=-committerdate refs/heads/
git for-each-ref --sort=-committerdate refs/heads/
Line 25: Line 25:
</pre>
</pre>


== Update Submodules ==
[https://stackoverflow.com/questions/1030169/pull-latest-changes-for-all-git-submodules pull-latest-changes-for-all-git-submodules]
<pre>
git submodule update --recursive --init
git submodule update --recursive --remote
</pre>
[[Category:Git]]
[[Category:Git]]

Revision as of 10:44, 6 July 2023

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/

Do a git diff between two branches

git diff <branch>..origin/<branch2>

Update Submodules

pull-latest-changes-for-all-git-submodules

git submodule update --recursive --init
git submodule update --recursive --remote