Bash-git-commands: Difference between revisions

From I Will Fear No Evil
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 14: Line 14:
<pre>
<pre>
sed -i 's|https://URL/|git@URL:|g' ./.gitmodules
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
sed -i 's|https://URL/|git@URL:|g' ./.git/modules/PATH/config
</pre>
</pre>

Revision as of 13:06, 22 October 2021

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