I have a local branch features
that I based off of my local master
to add some stuff in my code. I am now ready to merge those back into master
, however, the state of the remote master
branch has changed since then.
How can I get the latest version of master and then add my changes on top of that, so that I can then make a pull request to my remote master
branch.
I read a couple of similar articles here, but all of them gave different answers and I got confused.
Should I first "switch" to my master branch, do a git pull
and then somehow merge my features
branch into it (resolving any conflicts), or is there another way.
Some articles pointed out the usage of git checkout branch features
, but I am not sure what is the point in that. As far as I understand it git checkout
just switches to a certain branch.
Can anyone point me in a correct direction as to how I might approach this. Again, I just need to get the latest changes of my remote master
branch so that when I push my features
branch I dont get a ton of conflicts.
You need to pull before push, to make your local repository up-to-date before you push something (just in case someone else has already updated code on github.com ). This helps in resolving conflicts locally. 'origin' is a remote. You can use git remote --verbose to see all the remote configured under your git folder.
run git fetch to fetch latest changes, then run git rebase master to update your branch to the latest changes in master.
Indeed, git fetch pulls down the latest code from remote to origin/branch at local. If you have no local branch with the same name, then git checkout 2.1. 0 will create it for you, and checkout to that branch. But, if you have one already, then git checkout 2.1.
master
branch with: git checkout master
master
with: git pull origin master
features
with: git checkout features
master
branch over features
with: git merge master
git push origin features
Now, you have to create a new pull request from features
to master
. Done!
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