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:
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.
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
-- git checkout mybranch
-- git merge master (or rebase)
Till this it is correct
After this you are directly pushing to your branch, before this just add and commit like this.
-- git add .
-- git commit -m "msg after merging"
-- git push origin mybranch
This will merge Master Branch Code with your branch (i.e. mybranch) & will push the code to origin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With