DEV Community

Discussion on: Git Branching, Step-by-Step

Collapse
thadevelyouknow profile image
Funda Author

you mean switch to master, 'git checkout master', then switch back to branch and 'git push origin branch'? Yes...this is what I do, but I found with students too much switching caused confusion. It's either extra switching or extra merge conflicts.

Collapse
chiangs profile image
Stephen E. Chiang • Edited on

Maybe I'm confused, but I thought that if others have been working on their own branch and in the process of working on mine, a few PRs have been merged...so before I push to my remote and initiate a PR, I should git pull from the current master to my branch?

Kind of like this:

$ git add .
$ git commit -m "comments"
$ git pull origin master
$ git push origin myBranchName

Then open a PR.

Thread Thread
sergiopicciau profile image
Sergio Picciau

You can so you will eventually get conflicts on your feature branch and solve them before pushing to remote.

Thread Thread
thadevelyouknow profile image
Funda Author

that's in the steps now, edited ;-)

Thread Thread
chiangs profile image
Stephen E. Chiang

I see that in Step 5 you switch back to master to pull to your local copy of master, but how does that update your local branch without pulling master to your local branch?

I guess I still don't really understand why you would switch back to master and then back to branch. Thanks!

Thread Thread
leahein profile image
Leah Einhorn

Valid question. Just doing git pull origin master in Step 5 will NOT update your local branch. This tutorial is missing a step between 6 and 7. Essentially after you git pull origin master in Step 5, and git checkout mybranchname in step 6, you will run git merge master to combine the master branch changes into your feature branch, named mybranchname. Hope that helps!