Skip to content

Instantly share code, notes, and snippets.

@bavis-m
Created May 20, 2018 20:00
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 bavis-m/102224151e860fedfe9a6806935b84eb to your computer and use it in GitHub Desktop.
Save bavis-m/102224151e860fedfe9a6806935b84eb to your computer and use it in GitHub Desktop.
bash function for pushd-ing the directory of the Nth submodule in a git project
#!/usr/bin/env bash
pushmod() {
local root=`git rev-parse --show-toplevel`
local dir=`git config --file "$root/.gitmodules" --get-regexp path | cut -d" " -f2- | sed "\\\$q;${1:-1}q;d"`
pushd "$root/$dir"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment