about summary refs log tree commit diff stats
path: root/dev/git.html
blob: fdae528ffa9b1b8e42e84081e3e266a13f3d546e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<!DOCTYPEhtml>
<htmldir="ltr" lang="en">
<head>
    <meta charset='utf-8'>
    <title>Git</title>
</head>
<body>

    <a href="index.html">Dev Index</a>
    <h1>Git</h1>

    <p>First configure your global identity, configuration
    file resides on ~/.gitconfig ;</p>

    <pre>
       $ git config --global user.name "User Name"
       $ git config --global user.email user@devbox
    </pre>

    <p>Assumptions of this document;</p>

    <ul>
        <li>Correct
            <a href="../tools/gitolite.html#adminusers">user account</a>
            exists on git server or is public readable.
        </li>
        <li>Repository exists or
            <a href="../tools/gitolite.html#adminrep">create one</a>
            if you have permissions. This document uses atom as example.
        </li>
        <li>Correct
            <a href="../tools/openssh.html#sshid">ssh identities</a>,
            and profile alias have been setup. This document uses devbox as example.
        </li>
    </ul>

    <h2 id="teamwork">Team WorkFlow</h2>

    <p>This work flow is based on
    <a href="http://nvie.com/posts/a-successful-git-branching-model/">Vicent Driessen</a>,
    development model, it defines rules how branches are forked,
    merged and tagged. By having well defined set of branches,
    the project structure is used as a communication tool,
    allowing to work simultaneously on different stages
    of the development.</p>

    <pre>
       $ git clone devbox:atom
       $ git remote -v
    </pre>


    <h3>Main Branches;</h3>

    <dl>
        <dt>master</dt>
        <dd>Current official stable release history.</dd>
        <dt>release</dt>
        <dd>Next release, new features not allowed.</dd>
        <dt>develop</dt>
        <dd>Integration branch for features.</dd>
    </dl>

    <h3>Add-on Branches;</h3>

    <dl>
        <dt>feature</dt>
        <dd>New features, improvement proposal, tests, etc...</dd>
        <dt>hotfix</dt>
        <dd>Hotfix is branched of master and should only contain isolated bugfixes.</dd>
    </dl>

    <h2 id="feature">Feature</h2>

    <p>Create a branch and checkout;</p>

    <pre>
    $ git checkout -b featurex develop
    </pre>

    <p>Push new branch to server</p>

    <pre>
    $ git push -u origin featurex
    </pre>

    <p>Rename a branch;</p>

    <pre>
        $ git branch -m featurex feature-x
    </pre>

    <p>Rename remote branch;</p>

    <pre>
        $ git push origin :featurex feature-x
        $ git push origin -u feature-x
    </pre>

    <p>Merge branch feature into develop;</p>

    <pre>
       $ git checkout develop
       Switched to branch 'develop'
       $ git merge --no-ff feature-x
       Updating ea1b82a..05e9557
       (Summary of changes)
       $ git push origin develop
    </pre>

    <p>Delete Local;</p>

    <pre>
       $ git branch -D feature-x
    </pre>

    <p>Delete Remote</p>

    <pre>
       $ git push origin :feature-x
    </pre>

    <h2 id="release">Release</h2>

    <pre>
       $ git checkout -b release-1.2 develop
       Switched to a new branch "release-1.2"
       $ ./bump-version.sh 1.2
       Files modified successfully, version bumped to 1.2.
       $ git commit -a -m "Bumped version number to 1.2"
       [release-1.2 74d9424] Bumped version number to 1.2
       1 files changed, 1 insertions(+), 1 deletions(-)
    </pre>

    <p>Only documentation or bugfixes are allowed in this
    branch. When release is ready for production merge
    and push to master;</p>

    <pre>
       $ git checkout master
       Switched to branch 'master'
       $ git merge --no-ff release-1.2
       Merge made by recursive.
       (Summary of changes)
       $ git tag -a 1.2
    </pre>

    <p>Update branch develop with bugfixes from last release,
    conflict will happen in next step</p>

    <pre>
       $ git checkout develop
       Switched to branch 'develop'
       $ git merge --no-ff release-1.2
       Merge made by recursive.
       (Summary of changes)
    </pre>

    <h2 id="hotfix">Hotfix</h2>

    <p>This branch should never exist, ;)</p>

    <pre>
       $ git checkout -b hotfix-1.2.1 master
       $ ./bump-version.sh 1.2.1
       Files modified successfully, version bumped to 1.2.1
       $ git commit -a -m "Bumped version number to 1.2"
    </pre>

    <pre>
       $ git commit -m "Commit severe fixes"
    </pre>

    <pre>
       $ git checkout master
       Switched to branch 'master'
       $ git merge --no-ff release-1.2.1
       Merge made by recursive.
       (Summary of changes)
       $ git tag -a 1.2.1
    </pre>

    <p>Conflict will happen in next step</p>

    <pre>
       $ git checkout develop
       Switched to branch 'develop'
       $ git merge --no-ff release-1.2.1
       Merge made by recursive.
       (Summary of changes)
    </pre>

    <pre>
       $ git -D hotfix-1.2.1
    </pre>

    <h2 id="tags">Tags</h2>

    <pre>
    $ git tag -m "this commit is tagged" -a "v1.8"
    $ git push --follow-tags
    </pre>

    <p>Delete local and remote tag;</p>

    <pre>
    $ git tag -d v1.8
    $ git push origin :refs/tags/v1.8
    </pre>

    <h2 id="local">Local Workflow</h2>

    <p>Mark all deleted to commit;</p>

    <pre>
    $ git ls-files --deleted -z | xargs -0 git rm
    </pre>

    <p>Last commit that affected current path</p>

    <pre>
    $ git rev-list -n 1 HEAD -- .
    $ git show f000 path/to/file
    $ git diff --name-status f000 path/to/file
    </pre>

    <p>Undo a file to specific commit</p>

    <pre>
    $ git checkout f000^ -- path/to/file
    </pre>

    <a href="index.html">Dev Index</a>
    <p>This is part of the SysDoc Manual.
    Copyright (C) 2016
    Silvino Silva.
    See the file <a href="../fdl-1.3-standalone.html">Gnu Free Documentation License</a>
    for copying conditions.</p>


</body>
</html>