diff --git a/contributing/code/patches.rst b/contributing/code/patches.rst index d8ec09d7dfc..c8803ad874e 100644 --- a/contributing/code/patches.rst +++ b/contributing/code/patches.rst @@ -93,6 +93,29 @@ Set up your user information with your real name and a working email address: If you are new to Git, we highly recommend you to read the excellent and free `ProGit`_ book. +.. tip:: + + Windows users: when installing Git, the installer will ask what to do with + line endings and suggests to replace all Lf by CRLF. This is the wrong + setting if you wish to contribute to Symfony! Selecting the as-is method is + your best choice, as git will convert your line feeds to the ones in the + repository. If you have already installed Git, you can check the value of + this setting by typing: + + .. code-block:: bash + + $ git config core.autocrlf + + This will return either "false", "input" or "true", "true" and "false" being + the wrong values. Set it to another value by typing: + + .. code-block:: bash + + $ git config --global core.autocrlf input + + Replace --global by --local if you want to set it only for the active + repository + Get the Symfony2 source code: * Create a `GitHub`_ account and sign in; @@ -132,6 +155,11 @@ Create the topic branch with the following command: $ git checkout -b BRANCH_NAME master +.. tip:: + + Replace "master" by, for example, 2.0, if you wish to submit a patch to the + 2.0 branch. + .. tip:: Use a descriptive name for your branch (`ticket_XXX` where `XXX` is the @@ -215,6 +243,35 @@ with master, don't merge; and force the push to the origin: $ git rebase -f upstream/master $ git push -f origin BRANCH_NAME +.. note:: + + when doing a push -f (or --force), always specify the branch name explicitly + to avoid messing other branches in the repo (--force tells git that you + really want to mess with things so do it carefully). + +Often, moderators will ask you to "squash" your commits. This means you will +convert many commits to one commit. To do this, use the rebase command: + +.. code-block:: bash + + $ git rebase -i head~3 + $ git push -f origin BRANCH_NAME + +The number 3 here must equal the amount of commits in your branch. After you +type this command, an editor will popup showing a list of commits: + +.. code-block:: text + + pick 1a31be6 first commit + pick 7fc64b4 second commit + pick 7d33018 third commit + +To squash all commits into the first one, remove the word "pick" before the +second and the last commits, and replace it by the word "squash" or just "s". +When you save, git will start rebasing, and if succesful, will ask you to edit +the commit message, which by default is a listing of the commit messages of all +the commits. When you finish, execute the push command. + .. note:: All patches you are going to submit must be released under the MIT