git

Snippets

Set your commit email address in Git (source):

$ git config --global user.email "email@example.com"

Undo your most recent commit (source):

$ git commit -m "Something terribly misguided"
$ git reset HEAD~
<< edit files as necessary >>
$ git add ...
$ git commit -c ORIG_HEAD

Move an existing submodule within the same git repository (source):

git mv old/submod new/submod

Resolve a detached head (source):

git branch temp # base new branch on detached head
git checkout master
git merge temp
git branch -d temp

Make an empty commit (good for debugging CI):

git commit --allow-empty -m "Empty commit to trigger post_receive hooks"

Initialize all submodules recursively (source):

git submodule update --init --recursive

Last updated