33Pull request workflow
44=====================
55
6- .. highlight :: none
6+ .. highlight :: shell
77
88The so-called "PR workflow" used by Godot is common to many projects using
99Git, 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
3131issue tracker and PR system.
3232
3333.. 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 >`_.
3535
3636The Git version control system is the tool used to keep track of successive
3737edits to the source code - to contribute efficiently to Godot, learning the
3838basics of the Git command line is *highly * recommended. There exist some
3939graphical interfaces for Git, but they usually encourage users to take bad
4040habits 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
4242contributions (although it's tolerated for small fixes or documentation changes)
4343as it enforces one commit per file and per modification,
4444which 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
5050
5151The branches on the Git repository are organized as follows:
5252
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
5454 occurs. As a development branch, it can be unstable
5555 and is not meant for use in production. This is where PRs should be done
5656 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 ``
5959 branch to the currently maintained stable release (e.g. 3.0.2 or 2.1.5).
6060 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
6262 Godot 2.1).
6363 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.
6565- 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.
6767
6868Forking and cloning
6969-------------------
@@ -82,10 +82,10 @@ Godot repo, with your GitHub username as namespace:
8282
8383You can then *clone * your fork, i.e. create a local copy of the online
8484repository (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.
8787
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
8989 can use their respective terminals.
9090
9191To 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
102102working directory. Move into it using the ``cd `` command:
103103
104104::
105-
106- $ cd godot
105+
106+ $ cd godot
107107
108108We will start by setting up a reference to the original repository that we forked:
109109
@@ -112,10 +112,10 @@ We will start by setting up a reference to the original repository that we forke
112112 $ git remote add upstream https://github.com/godotengine/godot
113113 $ git fetch upstream
114114
115- This will create a reference named * upstream * pointing to the original
115+ This will create a reference named `` upstream `` pointing to the original
116116godotengine/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.
119119
120120You only need to do the above steps once, as long as you keep that local
121121``godot `` folder (which you can move around if you want, the relevant
@@ -139,26 +139,26 @@ file.
139139Branching
140140---------
141141
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
144144a feature branch:
145145
146146::
147147
148- // Create the branch based on the current branch (master)
148+ # Create the branch based on the current branch (master)
149149 $ git branch better-project-manager
150150
151- // Change the current branch to the new one
151+ # Change the current branch to the new one
152152 $ git checkout better-project-manager
153153
154154This command is equivalent:
155155
156156::
157157
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
159159 $ git checkout -b better-project-manager
160160
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:
162162
163163::
164164
@@ -177,14 +177,14 @@ command:
177177Updating your branch
178178--------------------
179179
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
184184in the meantime.
185185
186186To 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
188188*pulling * the upstream branch.
189189
190190::
@@ -195,10 +195,10 @@ However, if you had local commits, this method will create a so-called "merge
195195commit", and you will soon hear from fellow contributors that those are not
196196wanted in PRs. Then how to update the branch without creating a merge commit?
197197You 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
199199modify the Git history of your branch, but that is for the greater good.
200200
201- Then command that you should (almost) always use is there :
201+ Therefore, the command that you should (almost) always use is:
202202
203203::
204204
@@ -214,7 +214,7 @@ You would then do your changes to our example's
214214By default, those changes are *unstaged *. The staging area is a layer between
215215your working directory (where you make your modifications) and the local git
216216repository (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
218218*stage * them with the ``git add `` command, and then to commit them with the
219219``git commit `` command.
220220
@@ -233,7 +233,7 @@ before staging it, while it is staged, and after it has been committed.
233233 modifications.
234234- ``git commit `` will commit the staged files. It will open a text editor
235235 (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
237237 write a commit log. You can use ``git commit -m "Cool commit log" `` to
238238 write the log directly.
239239- ``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:
248248
249249::
250250
251- // It's nice to know where you're starting from
251+ # It's nice to know where you're starting from
252252 $ git log
253253
254- // Do changes to the project manager with the nano text editor
254+ # Do changes to the project manager with the nano text editor
255255 $ nano editor/project_manager.cpp
256256
257- // Find an unrelated bug in Control and fix it
257+ # Find an unrelated bug in Control and fix it
258258 $ nano scene/gui/control.cpp
259259
260- // Review changes
260+ # Review changes
261261 $ git status
262262 $ git diff
263263
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
266266 $ git add scene/gui/control.cpp
267267 $ git commit -m "Fix handling of margins in Control"
268268
269- // Check we did good
269+ # Check we did good
270270 $ git log
271271 $ git show
272272 $ git status
273273
274- // Make our second commit
274+ # Make our second commit
275275 $ git add editor/project_manager.cpp
276276 $ git commit -m "Add a pretty banner to the project manager"
277277 $ git log
278278
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
281281though, the remote fork does not know about them, nor does the upstream repo.
282282
283283Pushing changes to a remote
@@ -308,9 +308,9 @@ Issuing a pull request
308308----------------------
309309
310310When 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.
314314
315315.. image :: img/github_fork_make_pr.png
316316
@@ -321,7 +321,7 @@ If not (e.g. it has way more commits, or says there are merge conflicts),
321321don't create the PR, something went wrong. Go to IRC and ask for support :)
322322
323323Use 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,
325325to showcase what your work implements. Click "Create a pull request", and
326326tadaa!
327327
@@ -338,10 +338,10 @@ branch, push it to your fork, and the PR will be updated automatically:
338338
339339::
340340
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
342342 $ git checkout better-project-manager
343343
344- // Fix a mistake
344+ # Fix a mistake
345345 $ nano editor/project_manager.cpp
346346 $ git add editor/project_manager.cpp
347347 $ git commit -m "Fix a typo in the banner's title"
374374
375375::
376376
377- // The HEAD~X syntax means X commits before HEAD
377+ # The HEAD~X syntax means X commits before HEAD
378378 $ git rebase -i HEAD~2
379379
380380This will open a text editor with:
@@ -404,7 +404,7 @@ commits.
404404
405405.. note :: You could have avoided this rebase by using ``git commit --amend``
406406 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
408408 commit like we did in this example. So it is equivalent to what we
409409 did with a new commit and then a rebase to mark it as "fixup".
410410
@@ -434,22 +434,22 @@ And tadaa! Git will happily *replace* your remote branch with what you had
434434locally (so make sure that's what you wanted, using ``git log ``). This will
435435also update the PR accordingly.
436436
437- Deleting a Git Branch
437+ Deleting a Git branch
438438---------------------
439439
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
443443for the remote branch on GitHub.
444444
445- To delete our better project manager branch locally use this command:
445+ To delete our better project manager branch locally, use this command:
446446
447447::
448448
449- $ git branch -d better-project-manager
449+ $ git branch -d better-project-manager
450450
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 ``.
453453
454454Next, to delete the remote branch on GitHub use this command:
455455
0 commit comments