Reputation: 39871
When I want to update my code with the commits that are added in bitbucket what I do is I checkout branch A. Fetch the code from origin. And rebase the changes from origin/A on top of A. In this case it does not create new commits with different hashes. It repeats the same hashes we have on Bitbucket. But we all know that rebase deletes all commits on that specific branch and adds the same content commits on top of the commit we are currently. So why we don't have differnt SHA-1s?
Upvotes: 1
Views: 4067
Reputation: 531155
Git only creates new commits when the parent of an existing commit changes. In this case, you don't need to. Presumably, your local commit A
is the ancestor of the commits being copied from origin/A
, so you are essentially doing a fast-forward merge by rebasing origin/A
on top of A
. Or rather, you are simply advancing A
to be the same commit referenced by origin/A
. Graphically, you have before the rebase
A origin/A
* -- * -- * -- * -- * -- * -- *
and after the rebase
origin/A, A
* -- * -- * -- * -- * -- * -- *
No commits have changed; you've simply altered what A
references.
Upvotes: 6
Reputation: 2320
Because when you rebase - you change the base of your current changes that are not in remote/origin to what is currently in remote/origin. Basically this means - get everything from < from > and put it in my current branch, but keep my current work on top of everything in history to preserve the order of submission and linear history.
Upvotes: 0