142 | | Git hooks can be used in the same way for explicit syncing of Git repositories. Add the following to `.git/hooks/post-commit`: |
143 | | {{{#!sh |
144 | | #!/bin/sh |
145 | | REV=$(git rev-parse HEAD) |
146 | | trac-admin /path/to/env changeset added <repos> $REV |
| 142 | Git hooks can be used in the same way for explicit syncing of Git repositories. If your git repository is one that gets committed to directly on the machine that hosts trac, add the following to the `hooks/post-receive` file in your git repo (note: this will do nothing if you only update the repo by pushing to it): |
| 143 | {{{#!sh |
| 144 | #!/bin/sh |
| 145 | REV=$(git rev-parse HEAD) |
| 146 | trac-admin /path/to/env changeset added <repos> $REV |
| 147 | }}} |
| 148 | |
| 149 | Alternately, if your repository is one that only gets pushed to, add the following to the `hooks/post-receive` file in the repo: |
| 150 | {{{#!sh |
| 151 | #!/bin/sh |
| 152 | while read oldrev newrev refname; do |
| 153 | git rev-list --reverse $newrev ^$oldrev | \ |
| 154 | while read rev; do |
| 155 | trac-admin /path/to/env changeset added <repos> $rev |
| 156 | done |
| 157 | done |