| | 182 | For longer tasks, it is better to use a ''feature'' branch. A feature branch is off-shoot of '''develop''' that may be used for development of a new feature; the developer may commit changes as desired on the feature branch without affecting the '''develop''' branch. Once all the work is completed, the entire set of changes may then be merged back to '''develop''' (or discarded if the feature is not useful). '''git flow''' has a set of tools for managing feature branches, including creating from and merging back to '''develop'''. |
| | 183 | |
| | 184 | A few notes: |
| | 185 | - '''git flow''', like '''git''', prints out messages about what commands one may want to use later. |
| | 186 | - '''my_new_feature''' is the name of the feature branch. Any name may be used, although overlap of branch names and file names should be avoided to minimize confusion. |
| | 187 | - '''git flow''' only manages the ''__local__'' repository. Changes still have to be '''pull'''ed from and '''push'''ed to the remote repository. |
| | 188 | |
| | 189 | {{{#!html |
| | 190 | <pre style="margin-left:20px; margin-right:20px; border:solid 1px; padding:3px; background:white;"> |
| | 191 | <b style="color:#c22;">franklin:myrepo conrad$ pwd</b> |
| | 192 | /usr/local/projects/chimera2/git/myrepo |
| | 193 | <b style="color:#c22;">franklin:myrepo conrad$ git status</b> |
| | 194 | # On branch develop |
| | 195 | nothing to commit (working directory clean) |
| | 196 | <b style="color:#c22;">franklin:myrepo conrad$ git flow feature start my_new_feature</b> |
| | 197 | Switched to a new branch 'feature/my_new_feature' |
| | 198 | |
| | 199 | Summary of actions: |
| | 200 | - A new branch 'feature/my_new_feature' was created, based on 'develop' |
| | 201 | - You are now on branch 'feature/my_new_feature' |
| | 202 | |
| | 203 | Now, start committing on your feature. When done, use: |
| | 204 | |
| | 205 | git flow feature finish my_new_feature |
| | 206 | |
| | 207 | <b style="color:#c22;">franklin:myrepo conrad$ cat example</b> |
| | 208 | hello chimera2 |
| | 209 | <b style="color:#c22;">franklin:myrepo conrad$ echo "completely different" > example</b> |
| | 210 | <b style="color:#c22;">franklin:myrepo conrad$ git status</b> |
| | 211 | # On branch feature/my_new_feature |
| | 212 | # Changed but not updated: |
| | 213 | # (use "git add <file>..." to update what will be committed) |
| | 214 | # (use "git checkout -- <file>..." to discard changes in working directory) |
| | 215 | # |
| | 216 | # modified: example |
| | 217 | # |
| | 218 | no changes added to commit (use "git add" and/or "git commit -a") |
| | 219 | <b style="color:#c22;">franklin:myrepo conrad$ git add -A</b> |
| | 220 | <b style="color:#c22;">franklin:myrepo conrad$ git status</b> |
| | 221 | # On branch feature/my_new_feature |
| | 222 | # Changes to be committed: |
| | 223 | # (use "git reset HEAD <file>..." to unstage) |
| | 224 | # |
| | 225 | # modified: example |
| | 226 | # |
| | 227 | <b style="color:#c22;">franklin:myrepo conrad$ git commit -m "half done"</b> |
| | 228 | [feature/my_new_feature 8b5e441] half done |
| | 229 | 1 files changed, 1 insertions(+), 1 deletions(-) |
| | 230 | <b style="color:#c22;">franklin:myrepo conrad$ git status</b> |
| | 231 | # On branch feature/my_new_feature |
| | 232 | nothing to commit (working directory clean) |
| | 233 | <b style="color:#c22;">franklin:myrepo conrad$ echo "finished product" > example</b> |
| | 234 | <b style="color:#c22;">franklin:myrepo conrad$ git add -A</b> |
| | 235 | <b style="color:#c22;">franklin:myrepo conrad$ git commit -m "my new feature does this"</b> |
| | 236 | [feature/my_new_feature 2171ddf] my new feature does this |
| | 237 | 1 files changed, 1 insertions(+), 1 deletions(-) |
| | 238 | <b style="color:#c22;">franklin:myrepo conrad$ git flow feature finish my_new_feature</b> |
| | 239 | Switched to branch 'develop' |
| | 240 | Merge made by recursive. |
| | 241 | example | 2 +- |
| | 242 | 1 files changed, 1 insertions(+), 1 deletions(-) |
| | 243 | Deleted branch feature/my_new_feature (was 2171ddf). |
| | 244 | |
| | 245 | Summary of actions: |
| | 246 | - The feature branch 'feature/my_new_feature' was merged into 'develop' |
| | 247 | - Feature branch 'feature/my_new_feature' has been removed |
| | 248 | - You are now on branch 'develop' |
| | 249 | <b style="color:#c22;">franklin:myrepo conrad$ git push</b> |
| | 250 | Counting objects: 9, done. |
| | 251 | Delta compression using up to 64 threads. |
| | 252 | Compressing objects: 100% (5/5), done. |
| | 253 | Writing objects: 100% (7/7), 627 bytes, done. |
| | 254 | Total 7 (delta 4), reused 0 (delta 0) |
| | 255 | Unpacking objects: 100% (7/7), done. |
| | 256 | To /usr/local/projects/chimera2/git/chimera2.git |
| | 257 | a3108a9..fb5b90a develop -> develop |
| | 258 | |
| | 259 | </pre> |
| | 260 | }}} |
| | 261 | |