Skip to content

Instantly share code, notes, and snippets.

@tsathis
Last active February 11, 2021 02:26
Show Gist options
  • Save tsathis/e29cc17c69d43f36619e452e2cf19a98 to your computer and use it in GitHub Desktop.
Save tsathis/e29cc17c69d43f36619e452e2cf19a98 to your computer and use it in GitHub Desktop.
Favourite git commands.
# update the origin
git remote set-url origin <new-remote>
# add another repo as a submodule
git submodule add <that-repo-url> <folder-name-for-submodule>
# clone with submodules
git clone --recursive <url>
# download All submodules
git submodule update --init --recursive
# make a subdirectory the repo
git filter-branch --subdirectory-filter <folder> -- --all
# fetch the latest changes from upstream in each submodule, merge them in, and check out the latest revision of the submodule
git submodule update --remote --merge
# Git create empty branch
git checkout --orphan <branchname>
# commit branch with empty commit and then push.
git commit -m <commit message> --allow-empty
git push origin <newbranch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment