| | 15 | == Create Team Repository == |
| | 16 | |
| | 17 | In this section, examples refer to ''/var/tmp/conrad/example'' since the actual path ''/usr/local/projects/chimera2/git'' is already in use. Examples in other sections of this document refer to the correct path. |
| | 18 | |
| | 19 | Create the bare '''git''' repository that will serve as the team repository for Chimera 2 source code. Note that the repository is created for sharing within a group. The '''chgrp''' command defines which group will have cloning and update privileges. The access permissions such as the setgid bit of directories (meaning files created will inherit the group of the parent directory) in the repository is maintained by '''git''' and should not require manual intervention. |
| | 20 | |
| | 21 | {{{#!html |
| | 22 | <pre style="margin-left:20px; margin-right:20px; border:solid 1px; padding:3px; background:white;"> |
| | 23 | <b style="color:#c22;">franklin:example conrad$ cd /var/tmp/conrad/example</b> |
| | 24 | <b style="color:#c22;">franklin:example conrad$ git init --bare --shared=group chimera2.git</b> |
| | 25 | Initialized empty shared Git repository in /var/tmp/conrad/example/chimera2.git/ |
| | 26 | <b style="color:#c22;">franklin:example conrad$ chgrp -R chimdev chimera2.git</b> |
| | 27 | <b style="color:#c22;">franklin:example conrad$ ls -l</b> |
| | 28 | total 4 |
| | 29 | drwxrwsr-x 7 conrad chimdev 3864 May 1 09:34 chimera2.git/ |
| | 30 | </pre> |
| | 31 | }}} |
| | 32 | |
| | 33 | Create a bootstrap repository so that we can set up the initial configuration for the project. The reason this repository is temporary is that the push/pull linkage between local and remote branches need to be set up when the branches are created, but are handled automatically during cloning after they have been created. Since we will only use '''master''' and '''develop''' branches in the team repository, we can set them up now and developers who clone later will not have to worry about configuring the push/pull targets. |
| | 34 | |
| | 35 | {{{#!html |
| | 36 | <pre style="margin-left:20px; margin-right:20px; border:solid 1px; padding:3px; background:white;"> |
| | 37 | <b style="color:#c22;">franklin:example conrad$ git clone --shared chimera2.git bootstrap</b> |
| | 38 | Initialized empty Git repository in /var/tmp/conrad/example/bootstrap/.git/ |
| | 39 | warning: You appear to have cloned an empty repository. |
| | 40 | <b style="color:#c22;">franklin:example conrad$ cd bootstrap</b> |
| | 41 | /var/tmp/conrad/example/bootstrap |
| | 42 | <b style="color:#c22;">franklin:bootstrap conrad$ ls -la</b> |
| | 43 | total 12 |
| | 44 | drwxr-xr-x 3 conrad ferrin 3864 May 1 10:32 ./ |
| | 45 | drwxrwxr-x 5 conrad ferrin 3864 May 1 10:32 ../ |
| | 46 | drwxrwxr-x 7 conrad ferrin 3864 May 1 10:32 .git/ |
| | 47 | </pre> |
| | 48 | }}} |
| | 49 | |
| | 50 | Use '''git flow''' to set up the branches in the bootstrap repository. After initialization, we are on the '''develop''' branch where we add our initial files; '''xyzzy''' is our only file in this example. The '''add -A''' command adds all modified and untracked files to the staging area; the '''commit''' command commits files in the staging area to the local repository; the '''push''' command pushes the state of the current branch from the local repository, '''bootstrap''', to the remote team repository, '''origin''', which represents the repository from which we are cloned ('''chimera2.git''' in this case). |
| | 51 | |
| | 52 | {{{#!html |
| | 53 | <pre style="margin-left:20px; margin-right:20px; border:solid 1px; padding:3px; background:white;"> |
| | 54 | <b style="color:#c22;">franklin:bootstrap conrad$ git flow init -d</b> |
| | 55 | Using default branch names. |
| | 56 | No branches exist yet. Base branches must be created now. |
| | 57 | Branch name for production releases: [master] |
| | 58 | Branch name for "next release" development: [develop] |
| | 59 | |
| | 60 | How to name your supporting branch prefixes? |
| | 61 | Feature branches? [feature/] |
| | 62 | Release branches? [release/] |
| | 63 | Hotfix branches? [hotfix/] |
| | 64 | Support branches? [support/] |
| | 65 | Version tag prefix? [] |
| | 66 | <b style="color:#c22;">franklin:bootstrap conrad$ git status</b> |
| | 67 | # On branch develop |
| | 68 | nothing to commit (working directory clean) |
| | 69 | <b style="color:#c22;">franklin:bootstrap conrad$ echo hello > xyzzy</b> |
| | 70 | <b style="color:#c22;">franklin:bootstrap conrad$ git add -A</b> |
| | 71 | <b style="color:#c22;">franklin:bootstrap conrad$ git status</b> |
| | 72 | # On branch develop |
| | 73 | # Changes to be committed: |
| | 74 | # (use "git reset HEAD <file>..." to unstage) |
| | 75 | # |
| | 76 | # new file: xyzzy |
| | 77 | # |
| | 78 | <b style="color:#c22;">franklin:bootstrap conrad$ git commit -m "initial setup"</b> |
| | 79 | [develop ff9b042] initial setup |
| | 80 | 1 files changed, 1 insertions(+), 0 deletions(-) |
| | 81 | create mode 100644 xyzzy |
| | 82 | <b style="color:#c22;">franklin:bootstrap conrad$ git push origin develop</b> |
| | 83 | Counting objects: 5, done. |
| | 84 | Delta compression using up to 64 threads. |
| | 85 | Compressing objects: 100% (2/2), done. |
| | 86 | Writing objects: 100% (5/5), 384 bytes, done. |
| | 87 | Total 5 (delta 0), reused 0 (delta 0) |
| | 88 | Unpacking objects: 100% (5/5), done. |
| | 89 | To /var/tmp/conrad/example/chimera2.git |
| | 90 | * [new branch] develop -> develop |
| | 91 | </pre> |
| | 92 | }}} |
| | 93 | |
| | 94 | Make the '''master''' branch match the '''develop''' branch. The '''checkout''' command is used to switch from one branch to another; note that this command only uses the __local__ repository and does not require access to the team repository. |
| | 95 | |
| | 96 | {{{#!html |
| | 97 | <pre style="margin-left:20px; margin-right:20px; border:solid 1px; padding:3px; background:white;"> |
| | 98 | <b style="color:#c22;">franklin:bootstrap conrad$ git checkout master</b> |
| | 99 | Switched to branch 'master' |
| | 100 | You have new mail in /var/spool/mail/conrad |
| | 101 | <b style="color:#c22;">franklin:bootstrap conrad$ git merge develop</b> |
| | 102 | Updating 76fd917..ff9b042 |
| | 103 | Fast-forward |
| | 104 | xyzzy | 1 + |
| | 105 | 1 files changed, 1 insertions(+), 0 deletions(-) |
| | 106 | create mode 100644 xyzzy |
| | 107 | <b style="color:#c22;">franklin:bootstrap conrad$ git push origin master</b> |
| | 108 | Total 0 (delta 0), reused 0 (delta 0) |
| | 109 | To /var/tmp/conrad/example/chimera2.git |
| | 110 | * [new branch] master -> master |
| | 111 | </pre> |
| | 112 | }}} |
| | 113 | |
| | 114 | At this point, the team repository set up is complete. All the files are under revision control and the bootstrap repository may be safely deleted. The team repository, '''chimera2.git''', with '''master''' and '''develop''' branches, is ready for by developers. Note that developers still have to set up and use '''git flow''' after cloning in order to follow the [http://nvie.com/posts/a-successful-git-branching-model/ Vincent Driessen's branching model] conveniently. |
| | 115 | |
| | 116 | {{{#!html |
| | 117 | <pre style="margin-left:20px; margin-right:20px; border:solid 1px; padding:3px; background:white;"> |
| | 118 | <b style="color:#c22;">franklin:bootstrap conrad$ cd ..</b> |
| | 119 | <b style="color:#c22;">franklin:example conrad$ ls -l</b> |
| | 120 | total 12 |
| | 121 | drwxr-xr-x 3 conrad ferrin 3864 May 1 11:19 bootstrap/ |
| | 122 | drwxrwsr-x 7 conrad chimdev 3864 May 1 09:34 chimera2.git/ |
| | 123 | <b style="color:#c22;">franklin:example conrad$ rm -rf bootstrap</b> |
| | 124 | </pre> |
| | 125 | }}} |