| 322 | = Manage Your Code = |
| 323 | |
| 324 | |
| 325 | You may prefer to keep your application and development work in a git repository for all the good reasons that come with version control. For public repositories, you may like to try [https://github.com GitHub] or [https://bitbucket.org/ BitBucket]. RTEMS maintains mirrors on GitHub, which can make synchronizing with upstream changes relatively simple. If you need to keep your work private, you can use one of those services with private repositories or manage your own server. The details of setting up a server are outside the scope of this document, but if you have a server with ssh access you should be able to [http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-the-Server find instructions] on how to set up git access. Once you have git configured on the server, adding repositories is a snap. |
| 326 | = Private Servers = |
| 327 | |
| 328 | In the following, replace @USER@ with your username on your server, @REPO@ with the name of your repository, and @SERVER@ with your server's name or address. |
| 329 | |
| 330 | To push a mirror to your private server, first create a bare repository on your server. |
| 331 | {{{ |
| 332 | cd /home/@USER@ |
| 333 | mkdir git |
| 334 | mkdir git/@REPO@.git |
| 335 | cd git/@REPO@.git |
| 336 | git --bare init |
| 337 | }}} |
| 338 | Now from your client machine (e.g. your work laptop/desktop), push a git, perhaps one you cloned from elsewhere, or one that you made locally with 'git init', by adding a remote and pushing: |
| 339 | {{{ |
| 340 | git remote add @SERVER@ ssh://@SERVER@/home/@USER@/git/@REPO@.git |
| 341 | git push @SERVER@ master |
| 342 | }}} |
| 343 | You can replace the @SERVER@ with another name for your remote if you like. And now you can push other branches that you might have created. Now you can push and pull between your client and your server. |
| 344 | |
| 345 | The following is an example scenario that might be useful for RTEMS users that uses a slightly different approach than the one just outlined: |
| 346 | {{{ |
| 347 | ssh @SERVER@ |
| 348 | mkdir git |
| 349 | git clone --mirror git://git.rtems.org/rtems.git |
| 350 | ## Add your ssh key to ~/.ssh/authorized_keys |
| 351 | exit |
| 352 | git clone ssh://@SERVER@/home/@USER@/git/rtems.git |
| 353 | cd rtems |
| 354 | git remote add upstream git://git.rtems.org/rtems.git |
| 355 | git fetch upstream |
| 356 | git pull upstream master |
| 357 | git push |
| 358 | ## If you want to track RTEMS on your personal master branch, |
| 359 | ## you should only push changes to origin/master that you pull |
| 360 | ## from upstream. The basic workflow should look something like: |
| 361 | git checkout master |
| 362 | git pull upstream master |
| 363 | git push |
| 364 | git checkout -b anewbranch |
| 365 | ## Repeat: do work, git commit -a |
| 366 | git push origin anewbranch |
| 367 | |
| 368 | ## delete a remote branch |
| 369 | git push origin :anewbranch |
| 370 | ## delete a local branch |
| 371 | git branch -d anewbranch |
| 372 | }}} |
| 373 | |
| 374 | |