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 16: Line 16:
git submodule sync --recursive
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>
If you want to create a PR/MR in gitlab via the CLI
* you must have write privs
* Make very sure you are in a NEW branch so you do not screw things up.
** Using a date or epoch timestamp is reasonable
<pre>
git branch foo
git checkout foo
--- Make your changes ---
git add -A
git commit -m "Generic commit message"
git push -o merge_request.create -o merge_request.title="A spiffy title" -o merge_request.description="A short description"
</pre>
</pre>

Revision as of 18:56, 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

If you want to create a PR/MR in gitlab via the CLI

  • you must have write privs
  • Make very sure you are in a NEW branch so you do not screw things up.
    • Using a date or epoch timestamp is reasonable
git branch foo
git checkout foo
--- Make your changes ---
git add -A
git commit -m "Generic commit message"
git push -o merge_request.create -o merge_request.title="A spiffy title" -o merge_request.description="A short description"