Tom Jenkinson wrote on
12/6/18 3:38 AM:
As soon
as a commit in
your tree does
not have
identical SHA
to what is in
the main repo
it won't push
cleanly.
I don't understand.
How are two commits
considered to be "the
same" if not by their
SHA?
If there's a commit in
my repo that's not in
the remote, and
there's a commit in
the remote, that's not
in my repo, I
understand. But if I
do a "pull -r", how
can there be a commit
in the remote that I
don't have? Doesn't
"pull -r" pull down
everything from the
remote and add my
stuff on top of it,
without changing what
it pulled down?
I tried
to simulate it
a bit with
creating two
branches using
your current
master and
then on one of
the branches
doing a "git
commit --amend
--no-edit" so
although they
are both
functionally
identical both
branches have
a different
SHA for the
head commit.
"commit --amend" is
effectively the same
as completely removing
that commit and
replacing it with a
new commit, right?
I understand how that
would get things out
of sync, but I wasn't
doing that.
git diff
test2 (my
second branch)
- shows no
differences
but if I
do "git rebase
test2" it
changes the
branch I am on
to use the SHA
from the test2
branch.
History looks
clean still
but it can't
be clean
pushed.
If I do
"git merge
test2"
instead, it
can be pushed
but history
does not look
nice.
Here are
the branches:
There
reason they
all have
different SHA
is because the
second two
commits are in
a different
order. If
master was
going to have
exactly the
same commits
in the exact
same order you
could have
done "git
rebase EE4J_8"
each time and
it should have
pulled in the
lastest
commits
without
changing their
SHAs. In
practice I
don't see how
that would
have been
possible over
time as at
some point
they would
diverge.
Whenever
I try to sync
two branches I
cherry-pick
commits from
the branch
that is ahead
onto the other
branch. That
means that
history is not
re-written on
the branch I
am
cherry-picking
to and so I
don't need to
force push.
So you're saying that
rebase might rewrite
commits on the main
branch, not just add
commits from the other
branch? Ouch!
How does it know which
commits to rewrite?