Skip to content

Instantly share code, notes, and snippets.

@peey
Created June 23, 2020 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peey/668a528bffbee75485f72b83d4b4a3ab to your computer and use it in GitHub Desktop.
Save peey/668a528bffbee75485f72b83d4b4a3ab to your computer and use it in GitHub Desktop.
Add already checked out repo to git as submodule, automatically extract the remote URL from the repo on your local filesystem
#!/usr/bin/env fish
# based on https://stackoverflow.com/a/52127956/1412255
# tbh git should do better. It can record the particular commit and default remote
# instead of displaying "you accidentally added a git repo, did you mean to add a submodule?"
pushd $argv[1]
set url (git remote get-url (git remote))
popd
git submodule add $url $argv[1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment