Created
May 1, 2012 18:53
-
-
Save elazar/2570462 to your computer and use it in GitHub Desktop.
git mem/rec bash aliases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; These aliases are only useful if you work from a directory containing multiple repos. | |
; mem stores the current branch or commit checked out per repo to a specified file. | |
; rec reads a specified file in this format and restores the repos to their respective branches or commits. | |
; This is useful if you're working on or testing multiple branches together and/or simultaneously. | |
; | |
; Example: | |
; git mem /path/to/file | |
; [change repo configurations, do work, etc.] | |
; git rec /path/to/file | |
; [repos are now back in the configuration they were in when git mem was run] | |
[alias] | |
mem = "!sh -c 'for repo in *; do cd $repo; commit=$(git branch --no-color | sed -e \"/^[^*]/d\" -e \"s/^* //\"); if [ \"$commit\" = \"(no branch)\" ]; then commit=$(git rev-list --max-count=1 HEAD); fi; echo \"$repo $commit\"; cd ..; done > $1' -" | |
rec = "!sh -c 'cat $1 | while read repo commit; do cd $repo; git checkout $commit 2>&1 1>/dev/null; cd ..; done' -" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment