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>
>5 then result = result+1 x = 5 + width else x = x + width + 30 end end return result end function add_file_to_menu(x,y, s, cursor_highlight) local s_text = to_text(s) local width = App.width(s_text) if x + width > App.screen.width - 5 then y = y + Editor_state.line_height x = 5 end local color = Menu_background_color if cursor_highlight then color = Menu_highlight_color end button(Editor_state, 'menu', {x=x-5, y=y-2, w=width+5*2, h=Editor_state.line_height+2*2, color=colortable(color), onpress1 = function() navigate_to_file(s) end }) App.color(Menu_command_color) App.screen.draw(s_text, x,y) x = x + width + 30 return x,y end function navigate_to_file(s) move_candidate_to_front(s) local candidate = guess_source(s..'.lua') source.switch_to_file(candidate) reset_file_navigator() end function move_candidate_to_front(s) local index = array.find(File_navigation.all_candidates, s) assert(index) table.remove(File_navigation.all_candidates, index) table.insert(File_navigation.all_candidates, 1, s) end function reset_file_navigator() Show_file_navigator = false File_navigation.index = 1 File_navigation.filter = '' File_navigation.candidates = File_navigation.all_candidates end function keychord_press_on_file_navigator(chord, key) log(2, 'file navigator: '..chord) log(2, {name='file_navigator_state', files=File_navigation.candidates, index=File_navigation.index}) if chord == 'escape' then reset_file_navigator() elseif chord == 'return' then navigate_to_file(File_navigation.candidates[File_navigation.index]) elseif chord == 'backspace' then local len = utf8.len(File_navigation.filter) local byte_offset = Text.offset(File_navigation.filter, len) File_navigation.filter = string.sub(File_navigation.filter, 1, byte_offset-1) File_navigation.index = 1 File_navigation.candidates = source.file_navigator_candidates() elseif chord == 'left' then if File_navigation.index > 1 then File_navigation.index = File_navigation.index-1 end elseif chord == 'right' then if File_navigation.index < #File_navigation.candidates then File_navigation.index = File_navigation.index+1 end elseif chord == 'down' then file_navigator_down() elseif chord == 'up' then file_navigator_up() end end function log_render.file_navigator_state(o, x,y, w) -- duplicate structure of source.draw_file_navigator local num_lines = source.num_lines_for_file_navigator(o.files) local h = num_lines * Editor_state.line_height App.color(Menu_background_color) love.graphics.rectangle('fill', x,y, w,h) -- compute the x,y,width of the current index (in offsets from top left) local x2,y2 = 0,0 local width = 0 for i,filename in ipairs(o.files) do local filename_text = to_text(filename) width = App.width(filename_text) if x2 + width > App.screen.width - 5 then y2 = y2 + Editor_state.line_height x2 = 0 end if i == o.index then break end x2 = x2 + width + 30 end -- figure out how much of the menu to display local menu_xmin = math.max(0, x2-w/2) local menu_xmax = math.min(App.screen.width, x2+w/2) -- now selectively print out entries local x3,y3 = 0,y -- x3 is relative, y3 is absolute local width = 0 for i,filename in ipairs(o.files) do local filename_text = to_text(filename) width = App.width(filename_text) if x3 + width > App.screen.width - 5 then y3 = y3 + Editor_state.line_height x3 = 0 end if i == o.index then App.color(Menu_highlight_color) love.graphics.rectangle('fill', x + x3-menu_xmin - 5, y3-2, width+5*2, Editor_state.line_height+2*2) end if x3 >= menu_xmin and x3 + width < menu_xmax then App.color(Menu_command_color) App.screen.draw(filename_text, x + x3-menu_xmin, y3) end x3 = x3 + width + 30 end -- return h+20 end function file_navigator_up() local y, x, width = file_coord(File_navigation.index) local index = file_index(y-Editor_state.line_height, x, width) if index then File_navigation.index = index end end function file_navigator_down() local y, x, width = file_coord(File_navigation.index) local index = file_index(y+Editor_state.line_height, x, width) if index then File_navigation.index = index end end function file_coord(index) local y,x = Menu_status_bar_height, 5 for i,filename in ipairs(File_navigation.candidates) do local width = App.width(to_text(filename)) if x + width > App.screen.width - 5 then y = y + Editor_state.line_height x = 5 end if i == index then return y, x, width end x = x + width + 30 end end function file_index(fy, fx, fwidth) log_start('file index') log(2, ('for %d %d %d'):format(fy, fx, fwidth)) local y,x = Menu_status_bar_height, 5 local best_guess, best_guess_x, best_guess_width for i,filename in ipairs(File_navigation.candidates) do local width = App.width(to_text(filename)) if x + width > App.screen.width - 5 then y = y + Editor_state.line_height x = 5 end if y == fy then log(2, ('%d: correct row; considering %d %s %d %d'):format(y, i, filename, x, width)) if best_guess == nil then log(2, 'nil') best_guess = i best_guess_x = x best_guess_width = width elseif math.abs(fx + fwidth/2 - x - width/2) < math.abs(fx + fwidth/2 - best_guess_x - best_guess_width/2) then best_guess = i best_guess_x = x best_guess_width = width end log(2, ('best guess now %d %s %d %d'):format(best_guess, File_navigation.candidates[best_guess], best_guess_x, best_guess_width)) end x = x + width + 30 end log_end('file index') return best_guess end function text_input_on_file_navigator(t) File_navigation.filter = File_navigation.filter..t File_navigation.candidates = source.file_navigator_candidates() end