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
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
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
=head2 Sending patch emails
-After you've generated your patch you should sent it
-to perlbug@perl.org (as discussed L<in the previous
-section|/"Patch workflow">) with a normal mail client as an
+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
-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.
+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 RT
-#74192 and commit a4583001 for an example. Alternatively someone may
+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 RT
-#74532 and commit f9bcfeac for a bad example of this failure mode.
+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.
C<git help bisect> has much more information on how you can tweak your
binary searches.
+Following bisection you may wish to configure, build and test perl at
+commits identified by the bisection process. Sometimes, particularly
+with older perls, C<make> may fail during this process. In this case
+you may be able to patch the source code at the older commit point. To
+do so, please follow the suggestions provided in
+L<perlhack/Building perl at older commits>.
+
=head2 Topic branches and rewriting history
Individual committers should create topic branches under
B<yourname>/B<some_descriptive_name>:
- $ branch="$yourname/$some_descriptive_name"
- $ git checkout -b $branch
+ % branch="$yourname/$some_descriptive_name"
+ % git checkout -b $branch
... do local edits, commits etc ...
- $ git push origin -u $branch
+ % git push origin -u $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:
- $ git push origin $branch:refs/heads/$branch
- $ git config branch.$branch.remote origin
- $ git config branch.$branch.merge refs/heads/$branch
+ % git push origin $branch:refs/heads/$branch
+ % git config branch.$branch.remote origin
+ % git config branch.$branch.merge refs/heads/$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.
branch:
# first rebase
- $ git checkout $user/$topic
- $ git fetch
- $ git rebase origin/blead
+ % git checkout $user/$topic
+ % git fetch
+ % git rebase origin/blead
# then "delete-and-push"
- $ git push origin :$user/$topic
- $ git push origin $user/$topic
+ % 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
+ % 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
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,
+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
+ % 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:
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
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.
+A "smoke-me" branch is identified by the branch name: specifically, as
+seen on perl5.git.perl.org it must be a local branch whose first name
+component is precisely C<smoke-me>.
The procedure for doing this is roughly as follows (using the example of
of tonyc's smoke-me branch called 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
+ 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:
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
-C<http://users.perl5.git.perl.org/~yourlogin/>
+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<L<http://users.perl5.git.perl.org/~yourlogin/>>
These hosts have fairly strict firewalls to the outside. Outgoing, only
rsync, ssh and git are allowed. For http and ftp, you can use
-http://webproxy:3128 as proxy. Incoming, the firewall tries to detect
+L<http://webproxy:3128> as proxy. Incoming, the firewall tries to detect
attacks and blocks IP addresses with suspicious activity. This
sometimes (but very rarely) has false positives and you might get
blocked. The quickest way to get unblocked is to notify the admins.
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>.