| | 161 | = Development-related = #dev |
| | 162 | Various odds-and-ends related to tools and workarounds in coding sessions. |
| | 163 | == git server setup == |
| | 164 | A central git repository which things can be pushed to/pulled from, but no changes are directly made to, is a bare repository. These are good as central coordination/synchronization points for larger projects and/or if you work on a project from many locations. There are git commands for setting up a bare repo, but the following steps do roughly achieve the same thing. |
| | 165 | |
| | 166 | Here we assume that you have a git repo that you wish to make a bare repo from, and a host for your bare repo. The host should be running `git`, and you should have SSH access to it. |
| | 167 | |
| | 168 | 1. Copy the .git directory from your working git repo, and rename it. If your repo is named "project", the practice is to rename the .git taken from it to "project.git": |
| | 169 | {{{ |
| | 170 | $ cp -Rf project/.git project.git |
| | 171 | }}} |
| | 172 | 1. change "bare" to "true" in file `config` in project.git: |
| | 173 | {{{ |
| | 174 | [core] |
| | 175 | repositoryformatversion = 0 |
| | 176 | filemode = true |
| | 177 | bare = true |
| | 178 | logallrefupdates = true |
| | 179 | ... |
| | 180 | |
| | 181 | }}} |
| | 182 | 1. copy the new bare repo to your server. |
| | 183 | {{{ |
| | 184 | $ scp -r project.git [bare repo host]:[path to destination] |
| | 185 | }}} |
| | 186 | You should now be able to pull from/push to the host with the bare repository as usual. For example, with `git clone`: |
| | 187 | {{{ |
| | 188 | $ git clone ssh+git://[bare repo host]/path/to/project.git |
| | 189 | }}} |
| | 190 | You will be asked to authenticate with your SSH password. |
| | 191 | |
| | 192 | If you already have a local working directory, and you wish to start using your bare repo, just edit .git/config in your local git repo to point it to your server: |
| | 193 | {{{ |
| | 194 | ... |
| | 195 | |
| | 196 | [remote "origin"] |
| | 197 | fetch = +refs/heads/*:refs/remotes/origin/* |
| | 198 | url = ssh+git://[bare repo host]/path/to/project.git |
| | 199 | ... |
| | 200 | |
| | 201 | }}} |
| | 202 | Your changes to `config` will be applied starting with the next the git operation you do. |
| | 203 | |
| | 204 | ---- |