update page and remove duplicate content
[ikiwiki.git] / docs / developer / TypicalGitUsage.mdwn
1 [[!meta title="Mastering the DragonFly git repository"]]
2
3 [[!toc  levels=2]]
4
5 ## Clone the repository 
6
7 Look at the [[download]] page on how to clone the DragonFly repository. ***Note***: Please use a git mirror to reduce the bandwidth on the main servers.
8
9 ## Prepare patches 
10
11 If you (as a non-developer) made some changes to the DragonFly source and want to get them included in the main repository, send your patches to `submit@lists.dragonflybsd.org`. git assists you in creating patches which are easy to handle for the developers.
12
13 ### Example 
14
15  **Note:**  The change in this example is completely useless, it only serves demonstration purposes!
16
17
18
19 At first edit the files you want to change:
20
21     > vim README
22
23 Then review your changes with `git diff`:
24
25     
26
27     > git diff
28     diff --git a/README b/README
29     index 495a262..6a95d1f 100644
30     --- a/README
31     +++ b/README
32     @@ -59,7 +59,7 @@ lib           System libraries
33      
34      libexec                System daemons.
35      
36     -nrelease       Framework for building the ***live*** CD image.
37     +nrelease       Framework for building the ***live CD*** image.
38
39      sbin           System commands.
40
41      
42 If you are satisfied with your changes, commit them.   **Note:**  The first line of your commit message should describe your change in a small sentence.  Add more details after one newline.
43
44     
45
46     > git commit -a
47     ".git/COMMIT_EDITMSG" 10L, 342C written                                                                              
48     Created commit cbb871b: Change parentheses
49      1 files changed, 1 insertions(+), 1 deletions(-)
50
51 Now you can use `git format-patch` to generate a patch file.  This file is ready for submission to submit@. `git format-patch` will generate one file for every commit you did.
52
53     
54
55     > git format-patch origin
56     0001-Change-parentheses.patch
57     > cat 0001-Change-parentheses.patch
58     From cbb871b4588c695f000bc701b4f3c16a0a518991 Mon Sep 17 00:00:00 2001
59     From: Matthias Schmidt <matthiasdragonflybsd.org>
60     Date: Tue, 2 Dec 2008 09:54:47 +0100
61     Subject: [PATCH] Change parentheses
62
63     
64     ---
65      README |    2 +-
66      1 files changed, 1 insertions(+), 1 deletions(-)
67
68     
69
70     diff --git a/README b/README
71     index 495a262..6a95d1f 100644
72     --- a/README
73     +++ b/README
74     @@ -59,7 +59,7 @@ lib           System libraries.
75      
76      libexec                System daemons.
77
78     -nrelease       Framework for building the ***live*** CD image.
79     +nrelease       Framework for building the ***live CD*** image.     
80
81      sbin           System commands.
82     -- 
83     1.6.0.2
84
85     
86
87 Attach the generated files to a mail and submit it.  Write some lines about your intention and why you changed what ...
88
89
90
91 ## Working with branches 
92
93 It is  **not**  recommended to work directly in your  **master**  branch, except maybe for one-liners. Branches in git are very cheap, so just keep your  **master**  branch pure, and always work on a different local branch.
94
95 Say you want to work on a simple change. Just create a temporary branch, make the change and commit it.
96
97
98     
99     > git checkout -b work      # you're now in the work branch
100     > vim what/ever.c
101     > git commit -a
102
103 Now, you can switch back to  **master** , merge in the changes in your  **work**  branch and push away:
104
105
106
107     > git checkout master      # you're now in the master branch
108     > git merge work           # now master has your changes
109
110 Afterwards, you may (or not, if you want to do further development) want to delete the  **work**  branch by
111
112
113     > git branch -d work
114
115 For more complex changes, you probably want to create a longer-lived branch. For example
116
117
118     > git checkout -b myfeature
119
120 You can work in the  **myfeature**  branch until your feature is ready. You can commit there as often as you like. If your work goes on for a significant amount of time, you will want to merge with the upstream  **master**  from time to time. It is recommended that you use git rebase, so that the merge points won't show up in the repo history on crater (they don't really add much information). For this, you'd do:
121
122
123     > git checkout master
124     > git pull
125     > git checkout myfeature
126     > git rebase master
127
128
129 ## Push your work upstream 
130
131 When you judge that your code is ready for inclusion in mainline, you can merge it into your local  **master**  branch and push away:
132
133     
134
135     > git checkout master
136     > git merge myfeature
137     > git push crater
138
139
140 as the command will not push any branch that is not in the remote repository.
141