Skip to content

Instantly share code, notes, and snippets.

@devinrhode2
Last active March 17, 2023 15:35
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 devinrhode2/6e370ddfe824b1f49515f56e6314a434 to your computer and use it in GitHub Desktop.
Save devinrhode2/6e370ddfe824b1f49515f56e6314a434 to your computer and use it in GitHub Desktop.
git add-archive <sha>
[alias]
add-archive = "!runit() { REFS_BRANCH=`git branch -a --contains $1 | xargs` && \
NEW_REF=`echo refs/archive/$(date '+%Y-%m-%d')/$(git config user.name)/$REFS_BRANCH/$(date '+%s')` && \
git update-ref $NEW_REF $1 && \
echo consider deleting $REFS_BRANCH && \
echo attempting to backup archives && \
git push origin refs/archive/*:refs/archive/* && \
echo Here is your remote commit ref url && \
echo https://github.com/org/repo/commit/$1; }; runit"
@devinrhode2
Copy link
Author

git branch command may need --format=refname, or something similar, to remove prefixes like + and *.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment