5 This documentation assumes the reader is already familiary with using ``git``
6 for managing file revisions.
14 #. Go to https://gitlab.com/gromacs/gromacs
16 .. todo:: Link to GitLab docs for setting up an account, setting up git, and cloning repositories.
18 Uploading a commit for review
19 -----------------------------
21 Make sure your HEAD is up to date (use ``git pull --rebase origin`` if
22 someone else has committed since you last pulled), check that your commit
23 message follows the :doc:`commitstyle`.
25 Uploading a Work-In-Progress (WIP) or Private commit for review
26 ---------------------------------------------------------------
28 .. todo:: Note work-in-progress and privacy semantics.
33 Reviewing someone else's uploaded commit
34 ----------------------------------------
36 The reviewing workflow is the following:
38 #. https://gitlab.com/gromacs/gromacs/-/issues shows all open changes
39 #. A change needs a +2 and usually +1 review, as well as a +2 verified
40 to be allowed to be merged.
41 #. Usually a patch goes through several cycles of voting, commenting and
42 updating before it becomes merged, with votes from the developers indicating
43 if they think that change hat progressed enough to be included.
44 #. A change is submitted for merging and post-submit testing
45 by clicking "Submit" by one of the main developers. This should be done by
46 the reviewer after voting +2. After a patch is submitted it is
47 replicated to the main git server.
49 Do not review your own code. The point of the policy is that at least
50 two non-authors have voted +1, and that the issues are resolved in the
51 opinion of the person who applies a +2 before a merge. If you have
52 uploaded a minor fix to someone else's patch, use your judgement in
53 whether to vote on the patch +1.
58 - First and foremost, check correctness to the extent possible;
59 - As portability and performance are the most important things (after
60 correctness) do check for potential issues;
61 - Check adherence to the :ref:`GROMACS coding
62 standards <style-guidelines>`;
63 - We should try to ensure that commits that implement bugfixes (as
64 well as important features and tasks) get an `issue tracker`_ entry created
65 and linked. The linking is done **automatically** through
66 `special syntax <https://gitlab.com/help/user/markdown#special-gitlab-references>`__
67 - If the commit is a **bugfix**\ :
69 - if present in the `issue tracker`_, it has to contain a valid reference to the
71 - if it's a **major bug**, there has to be a bug report filed in the
72 `issue tracker`_ (with urgent or
73 immediate priority) and referenced appropriately.
75 - If the commit is a **feature/task** implementation:
77 - if it's present in the `issue tracker`_ it
78 has to contain a valid reference to the issue;
79 - If no current issue is currently present and the change
80 would benefit of one for future explanation on why it was
81 added, a new issue should be created.
86 .. rubric:: Q: Are there some other useful git configuration settings?
88 A: If you need to work with
89 branches that have large
90 differences (in particular, if a
91 lot of files have moved), it can
96 git config diff.renamelimit 5000
98 to increase the limit of inexact
99 renames that Git considers. The
100 default value is not sufficient,
101 for example, if you need to do a
102 merge or a cherry-pick from
103 a release branch to master.
105 .. rubric:: Q: How do I use git rebase (also ``git pull --rebase``)?
107 A: Assume you have a local
108 feature branch checked out, that
109 it is based on master, and master
110 has gotten new commits. You can
117 to move your commits on top of
118 the newest commit in master. This
119 will save each commit you did,
120 and replay them on top of master.
121 If any commit results in
122 conflicts, you need to resolve
123 them as usual (including marking
124 them as resolved using git add),
129 git rebase --continue
131 Note that unless you are sure
132 about what you are doing, you
133 should not use any commands that
134 create or delete commits (git
135 commit, or git checkout or git
136 reset without paths). ``git rebase
137 --continue`` will create the commit
138 after conflicts have been
139 resolved, with the original
140 commit message (you will get a
143 If you realize that the conflicts
144 are too messy to resolve (or that
145 you made a mistake that resulted
146 in messy conflicts), you can use
152 to get back into the state you
153 started from (before the
154 original git rebase master
155 invocation). If the rebase is
156 already finished, and you realize
157 you made a mistake, you can get
158 back where you started with
160 log <my-branch>@{1} and/or git
161 reflog <my-branch> to check that
162 this is where you want to go)
166 git reset --hard <my-branch>@{1}
168 .. rubric:: Q: How do I prepare several commits at once?
170 A: Assume I have multiple independent changes in my working tree.
177 to add one independent change at
178 a time to the index. Use
184 to check that the index contains
185 the changes you want. You can
186 then commit this one change:
192 If you want to test that the
193 change works, use to temporarily
194 store away other changes, and do
201 If the testing fails, you can
202 amend your existing commit with
203 ``git commit --amend``. After you are
204 satisfied, you can push the
205 commit for review. If
206 you stashed away your changes and
207 you want the next change to be
208 reviewed independently, do
212 git reset --hard HEAD^
215 (only do this if you pushed the
216 previous change upstream,
217 otherwise it is difficult to get
218 the old changes back!) and repeat
219 until each independent change is
220 in its own commit. If you skip
221 the ``git reset --hard`` step, you
222 can also prepare a local feature
223 branch from your changes.
225 .. rubric:: Q: How do I edit an earlier commit?
227 A: If you want to edit the latest
228 commit, you can simply do the
235 If you want to edit some other
236 commit, and commits after that
237 have not changed the same lines,
238 you can do the changes as usual
243 git commit --fixup <commit>
249 git commit --squash <commit>
251 where <commit> is the commit you
252 want to change (the difference is
253 that ``--fixup`` keeps the original
254 commit message, while ``--squash``
255 allows you to input additional
256 notes and then edit the original
257 commit message during ``git rebase
258 -i``). You can do multiple commits
259 in this way. You can also mix
260 ``--fixup/--squash`` commits with
261 normal commits. When you are
266 git rebase -i --autosquash <base-branch>
268 to merge the ``--fixup/--squash``
269 commits to the commits they
270 amend. See separate question on
271 ``git rebase -i`` on how to choose
274 In this kind of workflow, you
275 should try to avoid to change the
276 same lines in multiple commits
277 (except in ``--fixup/--squash``
278 commits), but if you have already
279 changed some lines and want to
280 edit an earlier commit, you can
285 git rebase -i <base-branch>
287 but you likely need to resolve
288 some conflicts later. See ``git
289 rebase -i`` question later.
291 .. rubric:: Q: How do I split a commit?
293 A: The instructions below apply
294 to splitting the HEAD commit; see
295 above how to use ``git rebase -i`` to
296 get an earlier commit as HEAD to
299 The simplest case is if you want
300 to split a commit A into a chain
301 A'-B-C, where A' is the first new
302 commit, and contains most of the
303 original commit, including the
304 commit message. Then you can do
308 git reset -p HEAD^ [-- <paths>]
311 to selectively remove parts from
312 commit A, but leave them in your
313 working tree. Then you can create
314 one or more commits of the
315 remaining changes as described in
318 If you want to split a commit A
319 into a chain where the original
320 commit message is reused for
321 something else than the first
322 commit (e.g., B-A'-C), then you
329 to remove the HEAD commit, but
330 leave everything in your working
331 tree. Then you can create your
332 commits as described in other
333 tips. When you come to a point
334 where you want to reuse the
335 original commit message, you can
342 to find how to refer to your
343 original commit as ``HEAD@{n}``, and
348 git commit -c HEAD@{n}
350 .. rubric:: Q: How do I use git rebase -i to only edit local commits?
352 A: Assume that you have a local
353 feature branch checked out, this
354 branch has three commits, and
355 that it is based on master.
356 Further, assume that master has
357 gotten a few more commits after
358 you branched off. If you want to
359 use ``git rebase -i`` to edit your
360 feature branch (see above), you
367 followed by a separate
373 The first command allows you to
374 edit your local branch without
375 getting conflicts from changes in
376 master. The latter allows you to
377 resolve those conflicts in a
378 separate rebase run. If you feel
379 brave enough, you can also do
380 both at the same time using