Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ee4j-build] git question

Hi Bill,

With Javamail repo, when you rebase its master on its EE4J_8 branch some of its commits on master have to be altered by git. These commits are the ones that are either not in the EE4J_8 branch at all and commits where they do not have identical SHAs to those in both branches). These commits get a new SHA and even if only a single commit has a different SHA you can't just "git push" anymore.

You can see the commit histories are different if you look at the bottom 3 commits in https://github.com/eclipse-ee4j/javamail/commits/master and https://github.com/eclipse-ee4j/javamail/commits/EE4J_8. Although the first commit is identical the following two commits are then in a different order and have different SHAs between the two branches.

The same principal can be seen if you do the following:
git reset --hard origin/master
git log -1 # look at the sha
git push
git commit --amend --no-edit
git log -1 # look at the sha now, you will see it is different even if the content of the commit appears identical
git push # this won't work because the commit history is different

This might not have been practical for your case, but generally if the commits had been in master first and then you had been able to rebased the EE4J_8 branch on master (or cherry-picked some commit) you would still have been able to "git push" to EE4J_8 branch because the SHAs would have already been pushed would not need to have been changed (unless you had added commits to EE4J_8 branch that were not on master, then you would be in the same position).

Does that help?
Tom

On Wed, 5 Dec 2018 at 17:23, Bill Shannon <bill.shannon@xxxxxxxxxx> wrote:
When I integrate pull requests I use rebase all the time, how is that different?

After doing the rebase, the push failed.  But I then did another pull with
rebase from the remote and then the push succeeded.  What did the pull pull
over that wasn't already in the local, since I did a pull before the rebase?

Does the rebase move the branch to the master and then the pull restores the
branch from the remote, so the same changes now appear on both the branch
and the master?  Does the push fail because the branch no longer exists in
the local copy and it has to be re-pulled from the remote?

Stuart Douglas wrote on 12/4/18 3:55 PM:
>
>
> On Wed, Dec 5, 2018 at 10:32 AM Bill Shannon <bill.shannon@xxxxxxxxxx
> <mailto:bill.shannon@xxxxxxxxxx>> wrote:
>
>     My question is how did the commit histories diverge?  (You can't really look
>     at the current history because I've merged the branches.)  I synced the
>     local with the remote by pulling everything from the remote, then I rebased
>     the branch on top of the stuff pulled from the remote.
>
>
> Branches always diverge, otherwise there is no point to having a branch. 
>  
>
>
>     Why did rebase cause something to appear in the remote that prevented me
>     from pushing to the remote?
>
>     Doesn't the rebase just add new commits on to the end the commit history
>     from the remote?
>
>
> No, rebase basically re-writes history (unless the branches could be fast
> forwarded). It will take the commits that are different on the branch you are
> on, and apply them on top of the base branch.
>
> Rebase is really for updating a feature branch in your personal fork, its not
> something you should do on an authoritative branch as it will mess up the
> history and require a force push. 
>
> If you want to move commits from one branch to another you should probably
> cherry-pick them.
>
> Stuart
>  
>
>
>
>     Tom Jenkinson wrote on 12/4/18 7:17 AM:
>>     I believe it is because the commit histories have diverged:
>>     https://github.com/eclipse-ee4j/javamail/commits/EE4J_8
>>     https://github.com/eclipse-ee4j/javamail/commits/master
>>     For example, you can see that the #338 commit has a different SHA on both
>>     branches.
>>
>>     My understanding is that as soon as the commit histories are different
>>     (different SHA) then you can't push them back without a force push because
>>     you will be re-writing history. More concretely for your case you can see
>>     after your steps if you do:
>>     `git commit -1`
>>     The sha will be different to the one on your current master:
>>     a16edc5d6e65a102ff169caef1d7b21a3b416591
>>     Trying to push that without the force flag leads to the error message you
>>     can see.
>>
>>     One option might be to cherry-pick the individual commits from the EE4J_8
>>     branch that you need, of course you will need to take care to make sure
>>     you got them all.
>>
>>
>>
>>     On Mon, 3 Dec 2018 at 21:49, Bill Shannon <bill.shannon@xxxxxxxxxx
>>     <mailto:bill.shannon@xxxxxxxxxx>> wrote:
>>
>>         Any git experts out there?  I've asked a few people locally but no one has
>>         really been able to explain this to me.
>>
>>         What am I doing wrong here?
>>
>>         javaxmail@datsunx$ git tag -a 1.6.3
>>         javaxmail@datsunx$ git push origin 1.6.3
>>         Counting objects: 1, done.
>>         Writing objects: 100% (1/1), 178 bytes | 178.00 KiB/s, done.
>>         Total 1 (delta 0), reused 0 (delta 0)
>>         To github.com:eclipse-ee4j/javamail.git
>>          * [new tag]         1.6.3 -> 1.6.3
>>         javaxmail@datsunx$ git checkout master
>>         Switched to branch 'master'
>>         Your branch is behind 'origin/master' by 1 commit, and can be
>>         fast-forwarded.
>>           (use "git pull" to update your local branch)
>>         javaxmail@datsunx$ git pull -r
>>         Updating beab926..8388a02
>>         Fast-forward
>>          mailapijar/pom.xml | 4 ++--
>>          1 file changed, 2 insertions(+), 2 deletions(-)
>>         Current branch master is up to date.
>>         javaxmail@datsunx$ git rebase EE4J_8
>>         First, rewinding head to replay your work on top of it...
>>         javaxmail@datsunx$ git push
>>         To github.com:eclipse-ee4j/javamail.git
>>          ! [rejected]        master -> master (non-fast-forward)
>>         error: failed to push some refs to
>>         'git@xxxxxxxxxx:eclipse-ee4j/javamail.git
>>         <mailto:git@xxxxxxxxxx:eclipse-ee4j/javamail.git>'
>>         hint: Updates were rejected because the tip of your current branch is
>>         behind
>>         hint: its remote counterpart. Integrate the remote changes (e.g.
>>         hint: 'git pull ...') before pushing again.
>>         hint: See the 'Note about fast-forwards' in 'git push --help' for details.
>>
>>         I don't understand why the git push is failing.
>>
>>         I updated the master branch, then rebased the EE4J_8 branch on top of it.
>>         Shouldn't it be ready to push at that point?
>>
>>         $ git pull -r
>>         First, rewinding head to replay your work on top of it...
>>         Applying: https://github.com/eclipse-ee4j/javamail/issues/336 release job
>>         Applying: Update to newest parent pom. (#341)
>>         Applying: Switch to jakarta coordinates.
>>         Applying: Update parent pom version and update JAF version.
>>         Applying: Update documentation for the move to Eclipse - fix #348
>>         Applying: JavaMail 1.6.3 Final Release.
>>         Applying: Update dependency javax.mail -> jakarta.mail.
>>         Applying: Change Java platform module system name to jakarta.mail.
>>         Applying: Don't include a version in the OSGi javax.activation dependency
>>
>>         What was in the remote master that wasn't pulled the first time?
>>         _______________________________________________
>>         ee4j-build mailing list
>>         ee4j-build@xxxxxxxxxxx <mailto:ee4j-build@xxxxxxxxxxx>
>>         To change your delivery options, retrieve your password, or
>>         unsubscribe from this list, visit
>>         https://www.eclipse.org/mailman/listinfo/ee4j-build
>>
>>
>>     _______________________________________________
>>     ee4j-build mailing list
>>     ee4j-build@xxxxxxxxxxx <mailto:ee4j-build@xxxxxxxxxxx>
>>     To change your delivery options, retrieve your password, or unsubscribe from this list, visit
>>     https://www.eclipse.org/mailman/listinfo/ee4j-build
>
>     _______________________________________________
>     ee4j-build mailing list
>     ee4j-build@xxxxxxxxxxx <mailto:ee4j-build@xxxxxxxxxxx>
>     To change your delivery options, retrieve your password, or unsubscribe from
>     this list, visit
>     https://www.eclipse.org/mailman/listinfo/ee4j-build
>
>
> _______________________________________________
> ee4j-build mailing list
> ee4j-build@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/ee4j-build
>
_______________________________________________
ee4j-build mailing list
ee4j-build@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/ee4j-build

Back to the top