"Stop.
Collaborate and Listen." ~ V. Ice
Enter fullscreen mode
Exit fullscreen mode
It is highly recommen...
For further actions, you may consider blocking this person and/or reporting abuse
Nice post Funda.
For STEP 4, I'd also suggest
git add -p
as a means of deciding which files to include. It lets you step through all your changes and give ay
orn
to decide what to stage.I love that. I am trying to be absolutely minimal (MVP) here, since this was written for the classroom & there is always a lot of confusion when students first encounter this. Perhaps I will add links to handle more shortcuts, best practices, and features.
👌
This is a nice article, however steps 9 and 10 should be swapped.
First you pull the updated master and then you remove the feature branch. Otherwise you will need to force branch delete (git branch -D) because your local repo doesn't know yet that the branch is already merged. And forcing is not nice ;).
Cheers!
yes this is right --- I will edit! And you are correct that forcing anything isn't nice at all.
Thank you for the improvement!
Should there be a
git merge master
between steps 6 and 7? I try to resolve conflicts, if any, before I submit the PR.Jeffrey,
Your question is valid 100%. after git checkout mybranchname we should perform a git merge master. It is at this stage that conflicts may appear and you have a chance to fix them. This way you make sure your branch won't conflict with the remote master branch.
Even more, when several developers are working release updates constantly to the master branch, we advise them to perform this sync process often to see how your changes operates in the whole application.
the merge happens on the website not from the terminal. This is for students to be able to visualize it in the GUI.
So are you saying that git pull origin master is not required? Why would I pull master locally then just push my branch up?
git pull origin master is being executed again at step 5. when you push to your branch it creates the pull request on the github website.
Updated with changes!
Hey Funda nice effort you've put in the article. I've also written an article on Manage Branches and Resolve Conflicts. Your Feedback would be welcome :)
cloudways.com/blog/manage-branches...
Hi Funda,
Shouldn't one pull from the master after committing changes to your branch so that you are up to date and can resolve and merge conflicts before doing the PR?
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.
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:
Then open a PR.
You can so you will eventually get conflicts on your feature branch and solve them before pushing to remote.
that's in the steps now, edited ;-)
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!
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 yougit pull origin master
in Step 5, andgit checkout mybranchname
in step 6, you will rungit merge master
to combine the master branch changes into your feature branch, namedmybranchname
. Hope that helps!You skipped a step between 4 and 5 - you forgot to create the pull request.
It’s implied in the ‘keep clicking green buttons’ part after you go to the Github site. I have edited this now to assume reader has collaborator permissions. You are right that if this were an open source project, the user would have to create a pull request. But these steps are for students who are just learning to become team collaborators, and for them, the pull request is created when you
push origin mybranchname
in terminal. Thank you!I really like using the following to flip back and forth between the two most recent branches. Saves time and having to remember some complicated branch name!
Thanks, Funda. This is a nice post. Some developer who started to git as a beginner should read this post. I'll share.
I love this post with that style,especially the beginning of group pictures! HaHa
Nice article! I suggest that in the first step a git pull -r will make a better branch highway.
Sweet - I am going to share it with my class
simple and useful