Bash-git-commands

From I Will Fear No Evil
Revision as of 13:06, 22 October 2021 by Chubbard (talk | contribs)
Jump to navigation Jump to search

Git commands that are useful for bash scripts.

  • Retrieve the hash for the current commit inside whatever branch we are in
  • This also works for submodules as long as you are within the submodule directory in question
git rev-parse HEAD
  • Change the git remote from http(s) to git@ can be done this way:
sed -i 's|https://URL/|git@URL:|g' ./.git/config
  • If you want to update the submodules
sed -i 's|https://URL/|git@URL:|g' ./.gitmodules
git submodule sync --recursive
sed -i 's|https://URL/|git@URL:|g' ./.git/modules/PATH/config