Out of band syncing to a local git branch.
This started as an experiment to see how commits could be created without
modifying the working directory, the index, or the state of HEAD. The end
result is like a cross between rsync
and git stash
using a specified
branch.
This allows you to deploy your current working directory:
- without polluting your master branch with build artifacts
- without modifying your current checkout at all:
- no branch switching
- no index clobbering
- no complaining about clobbering unstaged changes
Here's how you would use it to push your current working directory to a git push based hosting provider (like Heroku):
$ git-snapshot production
Creating branch 'production' if it doesn't exist...
Creating index... (this can take a while)
Creating tree from index...
Created tree 1e035b51027ba785c74155025cd616bbd20d8d17
Creating commit...
Created commit f2527eb28622d7a17403f723d36584027e595723
$ git push hosting production:master
In order of appearance:
- http://git-scm.com/docs/git-branch
- http://git-scm.com/docs/git-rev-parse
- http://git-scm.com/docs/git-ls-files
- http://git-scm.com/docs/git-hash-object
- http://git-scm.com/docs/git-update-index
- http://git-scm.com/docs/git-write-tree
- http://git-scm.com/docs/git-commit-tree
- http://git-scm.com/docs/git-update-ref
- Option to create tag instead of branch
- Specify commit message
- Don't do empty commits, it means the branch is already up to date
- Find portable replacement for
stat