Re: php-src is now on git
On Mon, Mar 19, 2012 at 3:07 PM, Christopher Jones <
[email protected]> wrote:
>
>
> On 03/19/2012 01:31 PM, Kris Craig wrote:
>
>> Here's what I wound-up doing: The merge entries on the workflow page now
>> contain "--no-ff" and I added an entry to the FAQ about the merge.ff option
>> available in newer clients. This way we should be covered either way. =)
>> --Kris
>>
>
> Is this supported by the php-src repo? This is what I get after using
> --no-ff:
>
> $ git push origin
> To https://git.php.net/**repository/php-src.git<https://git.php.net/repository/php-src.git>
> ! [rejected] PHP-5.3 -> PHP-5.3 (non-fast-forward)
> ! [rejected] PHP-5.4 -> PHP-5.4 (non-fast-forward)
> ! [rejected] master -> master (non-fast-forward)
> error: failed to push some refs to 'https://git.php.net/**
> repository/php-src.git <https://git.php.net/repository/php-src.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.
>
>
> --
> Email: [email protected]
> Tel: +1 650 506 8630
> Blog: http://blogs.oracle.com/opal/
>
>
That error can sometimes be misleading. I've noticed that it typically
happens if you're trying to push a branch containing merged commits to a
remote version of that branch that is newer than the one your commits were
merged into (i.e. you forgot to do a git pull followed by a git rebase
before doing the merge). I can't say for certain but that's a likely
possibility that that's what happened in your case.
Moving forward, we should probably add that to the workflow as it can save
a lot of headaches moving forward. Specifically, when merging in a branch:
1. git checkout <destination branch>
2. git pull [destination branch]
3. git checkout <feature branch>
4. git rebase <destination branch>
5. git checkout <destination branch>
6. git merge --no-ff <destination branch>
7. git push origin [destination branch]
8. git branch -d <feature branch>
What often happens is that you'll pull a branch then start working on a
feature branch. However, while you're doing that, somebody else pushes a
newer version of the branch you pulled. If you then merge into the older
"revision" of that branch without first making sure it's up-to-date,
everything will blow up in your face when you try to do a push. Despite
the migraines this tends to cause, it's actually a good thing that it does
this. After all, we don't *want* an older version of a branch being dumped
on top of a newer version. That would get very ugly lol. The only
downside is that the resulting error message when using --no-ff is
needlessly confusing for newcomers.
Assuming that's what happened in your case, you've got some damage control
to do. Whenever I'm training people in the office on using Git and they
make this inevitable mistake, I always tell them to think of the damage
control as good practice lol. =)
Anyway, assuming you haven't yet deleted the original feature branch, this
will be really easy:
1. git checkout -b <new backup branch name> <corrupted branch name>
- Creates a backup copy of the outdated branch with the merges.
2. git branch -D <corrupted branch name>
- Deletes the corrupted branch. Note that uppercase "-D" is required
since this is considered an "unsafe" delete.
3. git checkout -b <corrupted branch name> origin/<corrupted branch name>
- Re-creates the branch you just deleted, this time just grabbing the
one currently on the remote origin.
4. git checkout <feature branch>
- Checkout the feature branch that you originally merged into the
develop branch.
5. git rebase <corrupted branch name>
- Your feature branch will now be based off of the current develop
branch that you just pulled from the remote origin.
6. git checkout <corrupted branch name>
7. git merge --no-ff <feature branch>
- Merge the newly-rebased feature branch into this branch.
8. git push origin [corrupted branch name]
- Now your push should be successful.
I hope that helps! =)
--Kris
Thread (38 messages)