Git allows chronologically older commits to be applied after newer commits.
Because of this, the act of transferring commits between repositories is split into two steps:
Copying new commits from remote branch to copy of this remote branch inside local repo.
(repo to repo operation) master@remote >> remote/origin/master@local
Integrating new commits to local branch
(inside-repo operation) remote/origin/master@local >> master@local
There are two ways of doing step 2. You can:
- Fork local branch after last common ancestor and add new commits parallel to commits which are unique to local repository, finalized by merging commit, closing the fork.
- Insert new commits after last common ancestor and reapply commits unique to local repository.
In git
terminology, step 1 is git fetch
, step 2 is git merge
or git rebase
git pull
is git fetch
and git merge