36. Merging pulled changes
Goals
- Learn to get the fetched changes into the current branch and working directory.
01 Merge the pulled changes into the local main branch
Run
git merge origin/main
Result
$ git merge origin/main
Updating 39a1e0f..71df43a
Fast-forward
README | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
02 Check the README again
Now we should see the changes.
Run
cat README
Result
$ cat README
This is the Hello World example from the Git tutorial.
(changed in origin)
These are the changes. Although git fetch does not merge the changes, we can manually merge them from the remote repo.
03 The pull command
The fetch command gives you precise control over what is pulled and merged, but for convenience, there is also a command pull which fetches and merges changes from the remote branch into your current branch with one call.
git pull
...is equivalent to the following two steps:
git fetch
git merge origin/main