How to get changes from master branch to local branch?
git, git-merge
Solution
You can pull changes from master to your branch with:
git checkout my_branch # move on your branch (make sure it exists)
git fetch origin # fetch all changes
git pull origin master # pull changes from the origin remote, master branch and merge them into my_branch
git push origin my_branch # push my_branch
Please note, based on new changes to branch default name on some git repository providers you can have a master branch named main
Problem
I have, what I assume, is a typical workflow. Our project works with pull requests. To develop new feature I create a dev. branch. By the time I am finished with the feature some changes were made in master so I want to get those changes into my branch so I make pull request. From what I've read on the internet there are two options for that: - merge - rebase However, I tried both of them but when I make pull request it shows that all files were changed in this pr. Here is what I did: on the branch ``` -- git commit -a -m "changes i made on my branch" -- git checkout master -- git fetch upstream -- git merge upstream/master -- git checkout mybranch -- git merge master (or rebase) -- git push origin mybranch ``` result -- merge commit in the history shows files changes: 90 What is the correct way to get updates from master into my branch? Similar situation happens when somebody reviews my pr and I need to update my pr. Once again, I end up needing the changes from master. Thanks for the help.