I think I understand git pull
and this is how I explain it in, what I call, "simple terms":
- Generally speaking,
git pull
is about merging a "remote" branch into a "local" branch. - In more detail, git uses the content of the "remote" branch to "update" / "modify" content of the "local" branch.
- In even more detail, if a file has been modified in the "local" branch but not in the "remote" branch, then after the merge, the content of the file will be the same as the content in the "local" branch. The opposite is also true. If a file was modified on the "remote" branch but not in the "local" branch, the content will be taken from the "remote" branch.
- If a file was modified in both branches ("local" and "remote") than git will try to take modifications from both branches. If the changes happen on different places of the file, both changes will be applied and be present in the content of the file after the merge.
- If the changes happen on the same place we have what is know as a "merge conflict" and I am not going to touch this case for simplicity.
- As a result of the merge, we modify the "local" repository and therefore we need to "commit".
Now I want to get the same kind of explanation for git pull --rebase
. I do not want to use such terms as "head", "index", "fetch", "upstream" because these terms / concept only confuse beginners like me. I know that I need to learn these "advanced" concepts and I do it by reading tutorials but for now, as a part of my learning process, I want to understand git pull --rebase
.
ADDED
I think at some point I heard the following explanation. By git pull --rebase
. When we merge, we do it not in a "symmetric" way, as described above. Instead, we first "forget" the changes in the "local" repository and apply only the changes from the "remote" repository. By doing that we basically "copy" the remote repository as it is. After that we apply the changes from the "local" repository on top. However, it is still not clear to me what exactly it means. In particular, what "on top" means.