staged for the next commit, and usually some useful information about
how to change things. For instance the following:
- $ git status
- # On branch blead
- # Your branch is ahead of 'origin/blead' by 1 commit.
- #
- # Changes to be committed:
- # (use "git reset HEAD <file>..." to unstage)
- #
- # modified: pod/perlgit.pod
- #
- # Changed but not updated:
- # (use "git add <file>..." to update what will be committed)
- #
- # modified: pod/perlgit.pod
- #
- # Untracked files:
- # (use "git add <file>..." to include in what will be committed)
- #
- # deliberate.untracked
+ % git status
+ On branch blead
+ Your branch is ahead of 'origin/blead' by 1 commit.
+
+ Changes to be committed:
+ (use "git reset HEAD <file>..." to unstage)
+
+ modified: pod/perlgit.pod
+
+ Changes not staged for commit:
+ (use "git add <file>..." to update what will be committed)
+ (use "git checkout -- <file>..." to discard changes in working
+ directory)
+
+ modified: pod/perlgit.pod
+
+ Untracked files:
+ (use "git add <file>..." to include in what will be committed)
+
+ deliberate.untracked
This shows that there were changes to this document staged for commit,
and that there were further changes in the working directory not yet
staged. It also shows that there was an untracked file in the working
directory, and as you can see shows how to change all of this. It also
shows that there is one commit on the working branch C<blead> which has
-not been pushed to the C<origin> remote yet. B<NOTE>: that this output
+not been pushed to the C<origin> remote yet. B<NOTE>: This output
is also what you see as a template if you do not provide a message to
C<git commit>.
You can see what files are changed:
% git status
- # On branch orange
- # Changes to be committed:
- # (use "git reset HEAD <file>..." to unstage)
- #
- # modified: AUTHORS
- #
+ On branch orange
+ Changes to be committed:
+ (use "git reset HEAD <file>..." to unstage)
+
+ modified: AUTHORS
And you can see the changes:
- % git diff
- diff --git a/AUTHORS b/AUTHORS
- index 293dd70..722c93e 100644
- --- a/AUTHORS
- +++ b/AUTHORS
- @@ -541,7 +541,7 @@ Lars Hecking <lhecking@nmrc.ucc.ie>
- Laszlo Molnar <laszlo.molnar@eth.ericsson.se>
- Leif Huhn <leif@hale.dkstat.com>
- Len Johnson <lenjay@ibm.net>
- -Leon Brocard <acme@astray.com>
- +Orange Brocard <acme@astray.com>
- Les Peters <lpeters@aol.net>
- Lesley Binks <lesley.binks@gmail.com>
- Lincoln D. Stein <lstein@cshl.org>
+ % git diff
+ diff --git a/AUTHORS b/AUTHORS
+ index 293dd70..722c93e 100644
+ --- a/AUTHORS
+ +++ b/AUTHORS
+ @@ -541,7 +541,7 @@ Lars Hecking <lhecking@nmrc.ucc.ie>
+ Laszlo Molnar <laszlo.molnar@eth.ericsson.se>
+ Leif Huhn <leif@hale.dkstat.com>
+ Len Johnson <lenjay@ibm.net>
+ -Leon Brocard <acme@astray.com>
+ +Orange Brocard <acme@astray.com>
+ Les Peters <lpeters@aol.net>
+ Lesley Binks <lesley.binks@gmail.com>
+ Lincoln D. Stein <lstein@cshl.org>
Now commit your change locally:
- % git commit -a -m 'Rename Leon Brocard to Orange Brocard'
- Created commit 6196c1d: Rename Leon Brocard to Orange Brocard
- 1 files changed, 1 insertions(+), 1 deletions(-)
+ % git commit -a -m 'Rename Leon Brocard to Orange Brocard'
+ Created commit 6196c1d: Rename Leon Brocard to Orange Brocard
+ 1 files changed, 1 insertions(+), 1 deletions(-)
The C<-a> option is used to include all files that git tracks that you
have changed. If at this time, you only want to commit some of the
editor, git will write your change to disk and tell you something like
this:
- Created commit daf8e63: explain git status and stuff about remotes
- 1 files changed, 83 insertions(+), 3 deletions(-)
+ Created commit daf8e63: explain git status and stuff about remotes
+ 1 files changed, 83 insertions(+), 3 deletions(-)
If you re-run C<git status>, you should see something like this:
- % git status
- # On branch blead
- # Your branch is ahead of 'origin/blead' by 2 commits.
- #
- # Untracked files:
- # (use "git add <file>..." to include in what will be committed)
- #
- # deliberate.untracked
- nothing added to commit but untracked files present (use "git add" to track)
+ % git status
+ On branch orange
+ Untracked files:
+ (use "git add <file>..." to include in what will be committed)
+
+ deliberate.untracked
+
+ nothing added to commit but untracked files present (use "git add" to
+ track)
When in doubt, before you do anything else, check your status and read
it carefully, many questions are answered directly by the git status
Now you should create a patch file for all your local changes:
- % git format-patch -M origin..
+ % git format-patch -M blead..
0001-Rename-Leon-Brocard-to-Orange-Brocard.patch
+Or for a lot of changes, e.g. from a topic branch:
+
+ % git format-patch --stdout -M blead.. > topic-branch-changes.patch
+
You should now send an email to
L<perlbug@perl.org|mailto:perlbug@perl.org> with a description of your
changes, and include this patch file as an attachment. In addition to
L<perl5-porters@perl.org|mailto:perl5-porters@perl.org> directly if the
patch is not ready to be applied, but intended for discussion.
-See the next section for how to configure and use git to send these
-emails for you.
+Please do not use git-send-email(1) to send your patch. See L<Sending
+patch emails|/Sending patch emails> for more information.
If you want to delete your temporary branch, you may do so with:
- % git checkout blead
- % git branch -d orange
- error: The branch 'orange' is not an ancestor of your current HEAD.
- If you are sure you want to delete it, run 'git branch -D orange'.
- % git branch -D orange
- Deleted branch orange.
+ % git checkout blead
+ % git branch -d orange
+ error: The branch 'orange' is not an ancestor of your current HEAD.
+ If you are sure you want to delete it, run 'git branch -D orange'.
+ % git branch -D orange
+ Deleted branch orange.
=head2 Committing your changes
Assuming that you'd like to commit all the changes you've made as a
single atomic unit, run this command:
- % git commit -a
+ % git commit -a
(That C<-a> tells git to add every file you've changed to this commit.
New files aren't automatically added to your commit when you use
editor, git will write your change to disk and tell you something like
this:
- Created commit daf8e63: explain git status and stuff about remotes
- 1 files changed, 83 insertions(+), 3 deletions(-)
+ Created commit daf8e63: explain git status and stuff about remotes
+ 1 files changed, 83 insertions(+), 3 deletions(-)
If you re-run C<git status>, you should see something like this:
- % git status
- # On branch blead
- # Your branch is ahead of 'origin/blead' by 2 commits.
- #
- # Untracked files:
- # (use "git add <file>..." to include in what will be committed)
- #
- # deliberate.untracked
- nothing added to commit but untracked files present (use "git add" to track)
+ % git status
+ On branch blead
+ Your branch is ahead of 'origin/blead' by 2 commits.
+ (use "git push" to publish your local commits)
+ Untracked files:
+ (use "git add <file>..." to include in what will be committed)
+
+ deliberate.untracked
+
+ nothing added to commit but untracked files present (use "git add" to
+ track)
When in doubt, before you do anything else, check your status and read
it carefully, many questions are answered directly by the git status
output.
-=head2 Using git to send patch emails
-
-Please read L<perlhack> first in order to figure out where your patches
-should be sent.
-
-In your ~/git/perl repository, set the destination email to perl's bug
-tracker:
-
- $ git config sendemail.to perlbug@perl.org
-
-Or maybe perl5-porters:
-
- $ git config sendemail.to perl5-porters@perl.org
-
-Then you can use git directly to send your patch emails:
-
- $ git send-email 0001-Rename-Leon-Brocard-to-Orange-Brocard.patch
-
-You may need to set some configuration variables for your particular
-email service provider. For example, to set your global git config to
-send email via a gmail account:
-
- $ git config --global sendemail.smtpserver smtp.gmail.com
- $ git config --global sendemail.smtpssl 1
- $ git config --global sendemail.smtpuser YOURUSERNAME@gmail.com
-
-With this configuration, you will be prompted for your gmail password
-when you run 'git send-email'. You can also configure
-C<sendemail.smtppass> with your password if you don't care about having
-your password in the .gitconfig file.
+=head2 Sending patch emails
+
+After you've generated your patch you should send it
+to L<perlbug@perl.org|mailto:perlbug@perl.org> (as discussed L<in the
+previous section|/"Patch workflow">) with a normal mail client as an
+attachment, along with a description of the patch.
+
+You B<must not> use git-send-email(1) to send patches generated with
+git-format-patch(1). The RT ticketing system living behind
+L<perlbug@perl.org|mailto:perlbug@perl.org> does not respect the inline
+contents of E-Mails, sending an inline patch to RT guarantees that your
+patch will be destroyed.
+
+Someone may download your patch from RT, which will result in the
+subject (the first line of the commit message) being omitted. See
+L<RT #74192|https://rt.perl.org/Ticket/Display.html?id=74192> and
+L<commit a4583001|http://perl5.git.perl.org/perl.git/commitdiff/a4583001>
+for an example. Alternatively someone may
+apply your patch from RT after it arrived in their mailbox, by which
+time RT will have modified the inline content of the message. See
+L<RT #74532|https://rt.perl.org/Ticket/Display.html?id=74532> and
+L<commit f9bcfeac|http://perl5.git.perl.org/perl.git/commitdiff/f9bcfeac>
+for a bad example of this failure mode.
=head2 A note on derived files
process will overwrite them. Patch the originals instead. Most
utilities (like perldoc) are in this category, i.e. patch
F<utils/perldoc.PL> rather than F<utils/perldoc>. Similarly, don't
-create patches for files under $src_root/ext from their copies found in
-$install_root/lib. If you are unsure about the proper location of a
-file that may have gotten copied while building the source
-distribution, consult the C<MANIFEST>.
+create patches for files under F<$src_root/ext> from their copies found
+in F<$install_root/lib>. If you are unsure about the proper location of
+a file that may have gotten copied while building the source
+distribution, consult the F<MANIFEST>.
=head2 Cleaning a working directory
% git clean -Xf
to remove all ignored untracked files, such as build and test
-byproduct, but leave any manually created files alone.
+byproduct, but leave any manually created files alone.
If you only want to cancel some uncommitted edits, you can use C<git
checkout> and give it a list of files to be reverted, or C<git checkout
.../Porting/bisect.pl -e 'my $a := 2;'
-Using C<bisect.pl>, with one command (and no other files) it's easy to find
-out
+Using F<Porting/bisect.pl>, with one command (and no other files) it's easy to
+find out
=over 4
=back
usually without needing to know which versions of perl to use as start and
-end revisions, as F<bisect.pl> automatically searches to find the earliest
-stable version for which the test case passes. Run
+end revisions, as F<Porting/bisect.pl> automatically searches to find the
+earliest stable version for which the test case passes. Run
C<Porting/bisect.pl --help> for the full documentation, including how to
set the C<Configure> and build time options.
=head2 Topic branches and rewriting history
Individual committers should create topic branches under
-B<yourname>/B<some_descriptive_name>. Other committers should check
-with a topic branch's creator before making any change to it.
+B<yourname>/B<some_descriptive_name>:
-The simplest way to create a remote topic branch that works on all
-versions of git is to push the current head as a new branch on the
-remote, then check it out locally:
+ % branch="$yourname/$some_descriptive_name"
+ % git checkout -b $branch
+ ... do local edits, commits etc ...
+ % git push origin -u $branch
- $ branch="$yourname/$some_descriptive_name"
- $ git push origin HEAD:$branch
- $ git checkout -b $branch origin/$branch
+Should you be stuck with an ancient version of git (prior to 1.7), then
+C<git push> will not have the C<-u> switch, and you have to replace the
+last step with the following sequence:
-Users of git 1.7 or newer can do it in a more obvious manner:
+ % git push origin $branch:refs/heads/$branch
+ % git config branch.$branch.remote origin
+ % git config branch.$branch.merge refs/heads/$branch
- $ branch="$yourname/$some_descriptive_name"
- $ git checkout -b $branch
- $ git push origin -u $branch
+If you want to make changes to someone else's topic branch, you should
+check with its creator before making any change to it.
-If you are not the creator of B<yourname>/B<some_descriptive_name>, you
+You
might sometimes find that the original author has edited the branch's
history. There are lots of good reasons for this. Sometimes, an author
might simply be rebasing the branch onto a newer source point.
in the git push documentation for details) after you have rebased your
branch:
- # first rebase
- $ git checkout $user/$topic
- $ git fetch
- $ git rebase origin/blead
+ # first rebase
+ % git checkout $user/$topic
+ % git fetch
+ % git rebase origin/blead
- # then "delete-and-push"
- $ git push origin :$user/$topic
- $ git push origin $user/$topic
+ # then "delete-and-push"
+ % git push origin :$user/$topic
+ % git push origin $user/$topic
B<NOTE:> it is forbidden at the repository level to delete any of the
"primary" branches. That is any branch matching
C<m!^(blead|maint|perl)!>. Any attempt to do so will result in git
producing an error like this:
- $ git push origin :blead
- *** It is forbidden to delete blead/maint branches in this repository
- error: hooks/update exited with error code 1
- error: hook declined to update refs/heads/blead
- To ssh://perl5.git.perl.org/perl
- ! [remote rejected] blead (hook declined)
- error: failed to push some refs to 'ssh://perl5.git.perl.org/perl'
+ % git push origin :blead
+ *** It is forbidden to delete blead/maint branches in this repository
+ error: hooks/update exited with error code 1
+ error: hook declined to update refs/heads/blead
+ To ssh://perl5.git.perl.org/perl
+ ! [remote rejected] blead (hook declined)
+ error: failed to push some refs to 'ssh://perl5.git.perl.org/perl'
As a matter of policy we do B<not> edit the history of the blead and
maint-* branches. If a typo (or worse) sneaks into a commit to blead or
maint-*, we'll fix it in another commit. The only types of updates
-allowed on these branches are "fast-forward's", where all history is
+allowed on these branches are "fast-forwards", where all history is
preserved.
Annotated tags in the canonical perl.git repository will never be
deleted or modified. Think long and hard about whether you want to push
-a local tag to perl.git before doing so. (Pushing unannotated tags is
+a local tag to perl.git before doing so. (Pushing simple tags is
not allowed.)
=head2 Grafts
this mis-merge locally by adding the following line to your
C<.git/info/grafts> file:
- 296f12bbbbaa06de9be9d09d3dcf8f4528898a49 434946e0cb7a32589ed92d18008aaa1d88515930
+ 296f12bbbbaa06de9be9d09d3dcf8f4528898a49 434946e0cb7a32589ed92d18008aaa1d88515930
It is particularly important to have this graft line if any bisecting
is done in the area of the "merge" in question.
% git config --global user.name "Ævar Arnfjörð Bjarmason"
% git config --global user.email avarab@gmail.com
-However if you'd like to override that just for perl then execute then
+However, if you'd like to override that just for perl,
execute something like the following in F<perl>:
% git config user.email avar@cpan.org
First we need to create a temporary new branch for these changes and
switch into it:
- % git checkout -b experimental
+ % git checkout -b experimental
Patches that were formatted by C<git format-patch> are applied with
C<git am>:
- % git am 0001-Rename-Leon-Brocard-to-Orange-Brocard.patch
- Applying Rename Leon Brocard to Orange Brocard
+ % git am 0001-Rename-Leon-Brocard-to-Orange-Brocard.patch
+ Applying Rename Leon Brocard to Orange Brocard
+
+Note that some UNIX mail systems can mess with text attachments containing
+'From '. This will fix them up:
+
+ % perl -pi -e's/^>From /From /' \
+ 0001-Rename-Leon-Brocard-to-Orange-Brocard.patch
If just a raw diff is provided, it is also possible use this two-step
process:
- % git apply bugfix.diff
- % git commit -a -m "Some fixing" --author="That Guy <that.guy@internets.com>"
+ % git apply bugfix.diff
+ % git commit -a -m "Some fixing" \
+ --author="That Guy <that.guy@internets.com>"
Now we can inspect the change:
- % git show HEAD
- commit b1b3dab48344cff6de4087efca3dbd63548ab5e2
- Author: Leon Brocard <acme@astray.com>
- Date: Fri Dec 19 17:02:59 2008 +0000
-
- Rename Leon Brocard to Orange Brocard
-
- diff --git a/AUTHORS b/AUTHORS
- index 293dd70..722c93e 100644
- --- a/AUTHORS
- +++ b/AUTHORS
- @@ -541,7 +541,7 @@ Lars Hecking <lhecking@nmrc.ucc.ie>
- Laszlo Molnar <laszlo.molnar@eth.ericsson.se>
- Leif Huhn <leif@hale.dkstat.com>
- Len Johnson <lenjay@ibm.net>
- -Leon Brocard <acme@astray.com>
- +Orange Brocard <acme@astray.com>
- Les Peters <lpeters@aol.net>
- Lesley Binks <lesley.binks@gmail.com>
- Lincoln D. Stein <lstein@cshl.org>
+ % git show HEAD
+ commit b1b3dab48344cff6de4087efca3dbd63548ab5e2
+ Author: Leon Brocard <acme@astray.com>
+ Date: Fri Dec 19 17:02:59 2008 +0000
+
+ Rename Leon Brocard to Orange Brocard
+
+ diff --git a/AUTHORS b/AUTHORS
+ index 293dd70..722c93e 100644
+ --- a/AUTHORS
+ +++ b/AUTHORS
+ @@ -541,7 +541,7 @@ Lars Hecking <lhecking@nmrc.ucc.ie>
+ Laszlo Molnar <laszlo.molnar@eth.ericsson.se>
+ Leif Huhn <leif@hale.dkstat.com>
+ Len Johnson <lenjay@ibm.net>
+ -Leon Brocard <acme@astray.com>
+ +Orange Brocard <acme@astray.com>
+ Les Peters <lpeters@aol.net>
+ Lesley Binks <lesley.binks@gmail.com>
+ Lincoln D. Stein <lstein@cshl.org>
If you are a committer to Perl and you think the patch is good, you can
then merge it into blead then push it out to the main repository:
% git checkout blead
% git merge experimental
- % git push
+ % git push origin blead
If you want to delete your temporary branch, you may do so with:
- % git checkout blead
- % git branch -d experimental
- error: The branch 'experimental' is not an ancestor of your current HEAD.
- If you are sure you want to delete it, run 'git branch -D experimental'.
- % git branch -D experimental
- Deleted branch experimental.
+ % git checkout blead
+ % git branch -d experimental
+ error: The branch 'experimental' is not an ancestor of your current
+ HEAD. If you are sure you want to delete it, run 'git branch -D
+ experimental'.
+ % git branch -D experimental
+ Deleted branch experimental.
=head2 Committing to blead
Run the test suite. You might not think that one typo fix would break a
test file. You'd be wrong. Here's an example of where not running the
suite caused problems. A patch was submitted that added a couple of
-tests to an existing .t. It couldn't possibly affect anything else, so
-no need to test beyond the single affected .t, right? But, the
+tests to an existing F<.t>. It couldn't possibly affect anything else, so
+no need to test beyond the single affected F<.t>, right? But, the
submitter's email address had changed since the last of their
submissions, and this caused other tests to fail. Running the test
target given in the next item would have caught this problem.
changes. When this happens, your push will be rejected with a message
like this:
- To ssh://perl5.git.perl.org/perl.git
- ! [rejected] blead -> blead (non-fast-forward)
- error: failed to push some refs to 'ssh://perl5.git.perl.org/perl.git'
- To prevent you from losing history, non-fast-forward updates were rejected
- Merge the remote changes (e.g. 'git pull') before pushing again. See the
- 'Note about fast-forwards' section of 'git push --help' for details.
+ To ssh://perl5.git.perl.org/perl.git
+ ! [rejected] blead -> blead (non-fast-forward)
+ error: failed to push some refs to 'ssh://perl5.git.perl.org/perl.git'
+ To prevent you from losing history, non-fast-forward updates were
+ rejected Merge the remote changes (e.g. 'git pull') before pushing
+ again. See the 'Note about fast-forwards' section of 'git push --help'
+ for details.
When this happens, you can just I<rebase> your work against the new
position of blead, like this (assuming your remote for the master
repository is "p5p"):
- $ git fetch p5p
- $ git rebase p5p/blead
+ % git fetch p5p
+ % git rebase p5p/blead
You will see your commits being re-applied, and you will then be able to
push safely. More information about rebasing can be found in the
happened. Rebase as follows (assuming your work was on the
branch C<< committer/somework >>):
- $ git checkout committer/somework
- $ git rebase blead
+ % git checkout committer/somework
+ % git rebase blead
Then you can merge it into master like this:
- $ git checkout blead
- $ git merge --no-ff --no-commit committer/somework
- $ git commit -a
+ % git checkout blead
+ % git merge --no-ff --no-commit committer/somework
+ % git commit -a
The switches above deserve explanation. C<--no-ff> indicates that even
if all your work can be applied linearly against blead, a merge commit
And then push back to the repository:
- % git push
+ % git push origin blead
+
+=head2 Using a smoke-me branch to test changes
+
+Sometimes a change affects code paths which you cannot test on the OSes
+which are directly available to you and it would be wise to have users
+on other OSes test the change before you commit it to blead.
+
+Fortunately, there is a way to get your change smoke-tested on various
+OSes: push it to a "smoke-me" branch and wait for certain automated
+smoke-testers to report the results from their OSes.
+
+The procedure for doing this is roughly as follows (using the example of
+of tonyc's smoke-me branch called win32stat):
+
+First, make a local branch and switch to it:
+
+ % git checkout -b win32stat
+
+Make some changes, build perl and test your changes, then commit them to
+your local branch. Then push your local branch to a remote smoke-me
+branch:
+
+ % git push origin win32stat:smoke-me/tonyc/win32stat
+
+Now you can switch back to blead locally:
+
+ % git checkout blead
+
+and continue working on other things while you wait a day or two,
+keeping an eye on the results reported for your smoke-me branch at
+L<http://perl.develop-help.com/?b=smoke-me/tonyc/win32state>.
+
+If all is well then update your blead branch:
+
+ % git pull
+
+then checkout your smoke-me branch once more and rebase it on blead:
+
+ % git rebase blead win32stat
+
+Now switch back to blead and merge your smoke-me branch into it:
+
+ % git checkout blead
+ % git merge win32stat
+
+As described earlier, if there are many changes on your smoke-me branch
+then you should prepare a merge commit in which to give an overview of
+those changes by using the following command instead of the last
+command above:
+
+ % git merge win32stat --no-ff --no-commit
+
+You should now build perl and test your (merged) changes one last time
+(ideally run the whole test suite, but failing that at least run the
+F<t/porting/*.t> tests) before pushing your changes as usual:
+
+ % git push origin blead
+
+Finally, you should then delete the remote smoke-me branch:
+
+ % git push origin :smoke-me/tonyc/win32stat
+
+(which is likely to produce a warning like this, which can be ignored:
+
+ remote: fatal: ambiguous argument
+ 'refs/heads/smoke-me/tonyc/win32stat':
+ unknown revision or path not in the working tree.
+ remote: Use '--' to separate paths from revisions
+
+) and then delete your local branch:
+
+ % git branch -d win32stat
=head2 A note on camel and dromedary
C<users.perl5.git.perl.org> (I<dromedary>), which can be used for
general testing and development. Dromedary syncs the git tree from
camel every few minutes, you should not push there. Both machines also
-have a full CPAN mirror in /srv/CPAN, please use this. To share files
-with the general public, dromedary serves your ~/public_html/ as
+have a full CPAN mirror in F</srv/CPAN>, please use this. To share files
+with the general public, dromedary serves your F<~/public_html/> as
C<http://users.perl5.git.perl.org/~yourlogin/>
These hosts have fairly strict firewalls to the outside. Outgoing, only
These two boxes are owned, hosted, and operated by booking.com. You can
reach the sysadmins in #p5p on irc.perl.org or via mail to
-C<perl5-porters@perl.org>.
+L<perl5-porters@perl.org|mailto:perl5-porters@perl.org>.