3
3
Pull request workflow
4
4
=====================
5
5
6
- .. highlight :: none
6
+ .. highlight :: shell
7
7
8
8
The so-called "PR workflow" used by Godot is common to many projects using
9
9
Git, and should be familiar to veteran free software contributors. The idea
@@ -31,14 +31,14 @@ The `repository on GitHub <https://github.com/godotengine/godot>`_ is a
31
31
issue tracker and PR system.
32
32
33
33
.. note :: If you are contributing to the documention, its repository can
34
- be found `here <https://github.com/godotengine/godot-docs >`_.
34
+ be found `here <https://github.com/godotengine/godot-docs >`_.
35
35
36
36
The Git version control system is the tool used to keep track of successive
37
37
edits to the source code - to contribute efficiently to Godot, learning the
38
38
basics of the Git command line is *highly * recommended. There exist some
39
39
graphical interfaces for Git, but they usually encourage users to take bad
40
40
habits regarding the Git and PR workflow, and we therefore recommend not to
41
- use them. In particular, we advise not to use Github 's online editor for code
41
+ use them. In particular, we advise not to use GitHub 's online editor for code
42
42
contributions (although it's tolerated for small fixes or documentation changes)
43
43
as it enforces one commit per file and per modification,
44
44
which quickly leads to PRs with an unreadable Git history (especially after peer review).
@@ -50,20 +50,20 @@ which quickly leads to PRs with an unreadable Git history (especially after peer
50
50
51
51
The branches on the Git repository are organized as follows:
52
52
53
- - The * master * branch is where the development of the next major version
53
+ - The `` master `` branch is where the development of the next major version
54
54
occurs. As a development branch, it can be unstable
55
55
and is not meant for use in production. This is where PRs should be done
56
56
in priority.
57
- - The stable branches are named after their version, e.g. * 3.0 * and * 2.1 * .
58
- They are used to backport bugfixes and enhancements from the * master *
57
+ - The stable branches are named after their version, e.g. `` 3.0 `` and `` 2.1 `` .
58
+ They are used to backport bugfixes and enhancements from the `` master ``
59
59
branch to the currently maintained stable release (e.g. 3.0.2 or 2.1.5).
60
60
As a rule of thumb, the last stable branch is maintained until the next
61
- major version (e.g. the * 2.0 * branch was maintained until the release of
61
+ major version (e.g. the `` 2.0 `` branch was maintained until the release of
62
62
Godot 2.1).
63
63
If you want to make PRs against a maintained stable branch, you will have
64
- to check if your changes are also relevant for the * master * branch.
64
+ to check if your changes are also relevant for the `` master `` branch.
65
65
- There might be feature branches at time, usually meant to be merged into
66
- the * master * branch at some time.
66
+ the `` master `` branch at some time.
67
67
68
68
Forking and cloning
69
69
-------------------
@@ -82,10 +82,10 @@ Godot repo, with your GitHub username as namespace:
82
82
83
83
You can then *clone * your fork, i.e. create a local copy of the online
84
84
repository (in Git speak, the *origin remote *). If you haven't already,
85
- download Git from `its website <https://git-scm.com >`_ if you're using Windows or
86
- Mac, if you're using Linux install it through your package manager.
85
+ download Git from `its website <https://git-scm.com >`_ if you're using Windows or
86
+ macOS, or install it through your package manager if you're using Linux.
87
87
88
- .. note :: if you are on Windows open Git Bash to type commands. Mac and linux users
88
+ .. note :: If you are on Windows, open Git Bash to type commands. macOS and Linux users
89
89
can use their respective terminals.
90
90
91
91
To clone your fork from GitHub, use the following command:
@@ -102,8 +102,8 @@ After a little while, you should have a ``godot`` directory in your current
102
102
working directory. Move into it using the ``cd `` command:
103
103
104
104
::
105
-
106
- $ cd godot
105
+
106
+ $ cd godot
107
107
108
108
We will start by setting up a reference to the original repository that we forked:
109
109
@@ -112,10 +112,10 @@ We will start by setting up a reference to the original repository that we forke
112
112
$ git remote add upstream https://github.com/godotengine/godot
113
113
$ git fetch upstream
114
114
115
- This will create a reference named * upstream * pointing to the original
115
+ This will create a reference named `` upstream `` pointing to the original
116
116
godotengine/godot repository. This will be useful when you want to pull new
117
- commits from its * master * branch to update your fork. You have another
118
- * remote * reference named * origin * , which points to your fork.
117
+ commits from its `` master `` branch to update your fork. You have another
118
+ `` remote `` reference named `` origin `` , which points to your fork.
119
119
120
120
You only need to do the above steps once, as long as you keep that local
121
121
``godot `` folder (which you can move around if you want, the relevant
@@ -139,26 +139,26 @@ file.
139
139
Branching
140
140
---------
141
141
142
- By default, the ``git clone `` should have put you on the * master * branch of
143
- your fork (* origin * ). To start your own feature development, we will create
142
+ By default, the ``git clone `` should have put you on the `` master `` branch of
143
+ your fork (`` origin `` ). To start your own feature development, we will create
144
144
a feature branch:
145
145
146
146
::
147
147
148
- // Create the branch based on the current branch (master)
148
+ # Create the branch based on the current branch (master)
149
149
$ git branch better-project-manager
150
150
151
- // Change the current branch to the new one
151
+ # Change the current branch to the new one
152
152
$ git checkout better-project-manager
153
153
154
154
This command is equivalent:
155
155
156
156
::
157
157
158
- // Change the current branch to a new named one, based on the current branch
158
+ # Change the current branch to a new named one, based on the current branch
159
159
$ git checkout -b better-project-manager
160
160
161
- If you want to go back to the * master * branch, you'd use:
161
+ If you want to go back to the `` master `` branch, you'd use:
162
162
163
163
::
164
164
@@ -177,14 +177,14 @@ command:
177
177
Updating your branch
178
178
--------------------
179
179
180
- This would not be needed the first time, just after you forked the upstream
181
- repository. However, the next time you want to work on something, you will
182
- notice that your fork's * master * is several commits behind the upstream
183
- * master * branch: pull requests from other contributors would have been merged
180
+ This would not be needed the first time ( just after you forked the upstream
181
+ repository) . However, the next time you want to work on something, you will
182
+ notice that your fork's `` master `` is several commits behind the upstream
183
+ `` master `` branch: pull requests from other contributors would have been merged
184
184
in the meantime.
185
185
186
186
To ensure there won't be conflicts between the feature you develop and the
187
- current upstream * master * branch, you will have to update your branch by
187
+ current upstream `` master `` branch, you will have to update your branch by
188
188
*pulling * the upstream branch.
189
189
190
190
::
@@ -195,10 +195,10 @@ However, if you had local commits, this method will create a so-called "merge
195
195
commit", and you will soon hear from fellow contributors that those are not
196
196
wanted in PRs. Then how to update the branch without creating a merge commit?
197
197
You will have to use the ``--rebase `` option, so that your local commits are
198
- replayed on top of the updated upstream * master * branch. It will effectively
198
+ replayed on top of the updated upstream `` master `` branch. It will effectively
199
199
modify the Git history of your branch, but that is for the greater good.
200
200
201
- Then command that you should (almost) always use is there :
201
+ Therefore, the command that you should (almost) always use is:
202
202
203
203
::
204
204
@@ -214,7 +214,7 @@ You would then do your changes to our example's
214
214
By default, those changes are *unstaged *. The staging area is a layer between
215
215
your working directory (where you make your modifications) and the local git
216
216
repository (the commits and all the metadata in the ``.git `` folder). To
217
- bring changes from the working directory to the git repository, you need to
217
+ bring changes from the working directory to the Git repository, you need to
218
218
*stage * them with the ``git add `` command, and then to commit them with the
219
219
``git commit `` command.
220
220
@@ -233,7 +233,7 @@ before staging it, while it is staged, and after it has been committed.
233
233
modifications.
234
234
- ``git commit `` will commit the staged files. It will open a text editor
235
235
(you can define the one you want to use with the ``GIT_EDITOR `` environment
236
- variable or the ``core.editor `` setting in your Git config ) to let you
236
+ variable or the ``core.editor `` setting in your Git configuration ) to let you
237
237
write a commit log. You can use ``git commit -m "Cool commit log" `` to
238
238
write the log directly.
239
239
- ``git log `` will show you the last commits of your current branch. If you
@@ -248,36 +248,36 @@ Here's how the shell history could look like on our example:
248
248
249
249
::
250
250
251
- // It's nice to know where you're starting from
251
+ # It's nice to know where you're starting from
252
252
$ git log
253
253
254
- // Do changes to the project manager with the nano text editor
254
+ # Do changes to the project manager with the nano text editor
255
255
$ nano editor/project_manager.cpp
256
256
257
- // Find an unrelated bug in Control and fix it
257
+ # Find an unrelated bug in Control and fix it
258
258
$ nano scene/gui/control.cpp
259
259
260
- // Review changes
260
+ # Review changes
261
261
$ git status
262
262
$ git diff
263
263
264
- // We'll do two commits for our unrelated changes,
265
- // starting by the Control changes necessary for the PM enhancements
264
+ # We'll do two commits for our unrelated changes,
265
+ # starting by the Control changes necessary for the PM enhancements
266
266
$ git add scene/gui/control.cpp
267
267
$ git commit -m "Fix handling of margins in Control"
268
268
269
- // Check we did good
269
+ # Check we did good
270
270
$ git log
271
271
$ git show
272
272
$ git status
273
273
274
- // Make our second commit
274
+ # Make our second commit
275
275
$ git add editor/project_manager.cpp
276
276
$ git commit -m "Add a pretty banner to the project manager"
277
277
$ git log
278
278
279
- With this, we should have two new commits in our * better-project-manager *
280
- branch which were not in the * master * branch. They are still only local
279
+ With this, we should have two new commits in our `` better-project-manager ``
280
+ branch which were not in the `` master `` branch. They are still only local
281
281
though, the remote fork does not know about them, nor does the upstream repo.
282
282
283
283
Pushing changes to a remote
@@ -308,9 +308,9 @@ Issuing a pull request
308
308
----------------------
309
309
310
310
When you load your fork's branch on GitHub, you should see a line saying
311
- "This branch is 2 commits ahead of godotengine:master." (and potentially some
312
- commits behind, if your * master * branch was out of sync with the upstream
313
- * master * branch.
311
+ * "This branch is 2 commits ahead of godotengine:master." * (and potentially some
312
+ commits behind, if your `` master `` branch was out of sync with the upstream
313
+ `` master `` branch.
314
314
315
315
.. image :: img/github_fork_make_pr.png
316
316
@@ -321,7 +321,7 @@ If not (e.g. it has way more commits, or says there are merge conflicts),
321
321
don't create the PR, something went wrong. Go to IRC and ask for support :)
322
322
323
323
Use an explicit title for the PR and put the necessary details in the comment
324
- area. You can drag and drop screenshots, gifs or zipped projects if relevant,
324
+ area. You can drag and drop screenshots, GIFs or zipped projects if relevant,
325
325
to showcase what your work implements. Click "Create a pull request", and
326
326
tadaa!
327
327
@@ -338,10 +338,10 @@ branch, push it to your fork, and the PR will be updated automatically:
338
338
339
339
::
340
340
341
- // Check out your branch again if you had changed in the meantime
341
+ # Check out your branch again if you had changed in the meantime
342
342
$ git checkout better-project-manager
343
343
344
- // Fix a mistake
344
+ # Fix a mistake
345
345
$ nano editor/project_manager.cpp
346
346
$ git add editor/project_manager.cpp
347
347
$ git commit -m "Fix a typo in the banner's title"
374
374
375
375
::
376
376
377
- // The HEAD~X syntax means X commits before HEAD
377
+ # The HEAD~X syntax means X commits before HEAD
378
378
$ git rebase -i HEAD~2
379
379
380
380
This will open a text editor with:
@@ -404,7 +404,7 @@ commits.
404
404
405
405
.. note :: You could have avoided this rebase by using ``git commit --amend``
406
406
when fixing the typo. This command will write the staged changes
407
- directly into the *last * commit (* HEAD * ), instead of creating a new
407
+ directly into the *last * commit (`` HEAD `` ), instead of creating a new
408
408
commit like we did in this example. So it is equivalent to what we
409
409
did with a new commit and then a rebase to mark it as "fixup".
410
410
@@ -434,22 +434,22 @@ And tadaa! Git will happily *replace* your remote branch with what you had
434
434
locally (so make sure that's what you wanted, using ``git log ``). This will
435
435
also update the PR accordingly.
436
436
437
- Deleting a Git Branch
437
+ Deleting a Git branch
438
438
---------------------
439
439
440
- After your pull request gets merged there's one last thing you should do, delete your
441
- Git branch for the PR. There wont be issues if you don't delete your branch, but it's
442
- good practice to do so. You'll need to do this twice, once for the local branch and another
440
+ After your pull request gets merged, there's one last thing you should do: delete your
441
+ Git branch for the PR. There won't be issues if you don't delete your branch, but it's
442
+ good practice to do so. You'll need to do this twice, once for the local branch and another
443
443
for the remote branch on GitHub.
444
444
445
- To delete our better project manager branch locally use this command:
445
+ To delete our better project manager branch locally, use this command:
446
446
447
447
::
448
448
449
- $ git branch -d better-project-manager
449
+ $ git branch -d better-project-manager
450
450
451
- Alternatively, if the branch hadn't been merged yet and we wanted to delete it anyway, instead
452
- of ``-d `` you would use ``-D ``.
451
+ Alternatively, if the branch hadn't been merged yet and we wanted to delete it anyway, instead
452
+ of ``-d `` you would use ``-D ``.
453
453
454
454
Next, to delete the remote branch on GitHub use this command:
455
455
0 commit comments