Skip to content

Instantly share code, notes, and snippets.

@mstraughan86
Last active December 9, 2017 19:11
Show Gist options
  • Save mstraughan86/49a507603c9e63e3e1f7eb73c8933b9c to your computer and use it in GitHub Desktop.
Save mstraughan86/49a507603c9e63e3e1f7eb73c8933b9c to your computer and use it in GitHub Desktop.
Git Utility Shelf

Sometimes contributions don't count. Why?

How do you upload a file to GitHub, then lock it so that git will no longer check for and push updates on that file, to preserve a local customized copy?

Source

git update-index --skip-worktree FILE_NAME
git update-index --no-skip-worktree FILE_NAME

How do you pre/post date the very next commit?

Only in Bash:

GIT_AUTHOR_DATE='Sun Sep 10 20:00:00 2017 -0700' GIT_COMMITTER_DATE='Sun Sep 10 20:00:00 2017 -0700' git commit -m 'Commit Message here.'

ADD A SUBTREE:

git remote add -f Mercury git@github.com:mstraughan86/Mercury.git
git merge -s ours --no-commit --allow-unrelated-histories Mercury/master
git read-tree --prefix=lib/Mercury -u Mercury/master
git commit -m "Subtree merged in Mercury"

PUSH:

git subtree push --prefix=lib/Mercury Mercury master

PUSH, then FAIL:

git push Mercury $(git subtree split --prefix=lib/Mercury --onto=Mercury/master):master

PULL:

git subtree pull --prefix=lib/Mercury Mercury master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment