Creating an Open Source JavaScript Library on Github

Moving to the Master Branch

Kent C. Dodds

Kent C. Dodds

Professional Trainer
Creating an Open Source JavaScript Library on Github

Check out a free preview of the full Creating an Open Source JavaScript Library on Github course

The "Moving to the Master Branch" Lesson is part of the full, Creating an Open Source JavaScript Library on Github course featured in this preview video. Here's what you'd learn in this lesson:

Kent unintentionally forked the Star Wars Names library on the wrong branch. To fix this, he leads the group through moving their projects back to the master branch.


Transcript from the "Moving to the Master Branch" Lesson

>> [MUSIC]

>> Kent C Dodds: Don't worry about creating the Travis.yml right now, and just worry about updating all of this stuff and.
>> Kent C Dodds: Yeah, let's see, I actually hadn't thought about the fact that we're on a separate branch altogether. You're gonna wanna watch this one too. So, we're gonna go ahead and create a new branch.

So git branch, shoot, no, I have an alias for creating a new branch, and now I can't remember how to do it normally. gitconfig. Yeah, yeah. git checkout -b [LAUGH], and we'll just call this one (temp) --no-verify. I think we've got some stuff kind of broken here. Hold on.

Yeah, and then we'll git add everything, so sorry, these are the commands, git checkout, whatever you wanna call it, whatever you wanna call your temporary branch. We'll just call it (temp) --no-verify, and then we'll git commit -an 'it is mine!'. Commit that. This error that we're getting is because we cloned this thing anew.

And we haven't installed all the dependencies yet. And so, git hooks is having trouble. So, you don't need to worry about it, you just go ahead and no-verify. Okay, what is that?
>> Kent C Dodds: That's weird, go ahead and remove your node mod. Well, goodness gracious, what is this?
>> Kent C Dodds: Okay, so we're gonna just get rid of our git hooks.

However you remove directories in your platform, I'm using rm -rf, and this would be in .git/hook, just delete that. And then you won't need to worry about git hooks.
>> Kent C Dodds: And then, we're going to totally swap out the Master branch with our temporary branch that we made, and push that, yeah.

I knew this was gonna be really complicated [LAUGH]. I hope that some people are able to follow along. We will have time to let you do this. I really love to have a couple of people at least to be able to publish this stuff.
>> Student: So, right now we're on the 0.8 branch, right?

>> Kent C Dodds: Yeah, we're making changes from the 0.8 branch. And so you make all of your changes, and then you check out a new branch called temp. And then we're going to, let's see, git branch -D, so with a capital D, master. Once I'm done with doing all this stuff, I'm gonna take all these commands and I'll put them in the chat.

So, don't worry about memorizing all these commands. So we're gonna delete the master branch. And then we're gonna move temp to master.
>> Kent C Dodds: Bad source. Source is temp, destination is master.
>> Kent C Dodds: Wait, no, that's not the command. It's branch, okay. Change then name of the branch get. I Google sometimes, yeah.

git branch -m temp master. Okay so now you're on master, you can git push -f to force push on master, which is something you should never ever do except right now. [LAUGH] Okay and that's as far as I want you to get, so a lot of stuff, let me put all this stuff in the chat, yeah and then.

>> Student: So where'd you get the temp name?
>> Kent C Dodds: I just made it up.
>> Student: Did you rename or did you-
>> Kent C Dodds: So that happened when I-
>> Student: Checked it out?
>> Kent C Dodds: Yeah, when I checked out the new branch, so before I was on browser build, and then I said git checkout, create new branch called temp.

>> Student: I didn't see that, okay.
>> Kent C Dodds: Yeah, so that's why I'm gonna copy all these to the chat so you all can see it. But yeah, then hopefully we can get some of you onto this stuff. So let me pull up Frontend Masters chat here.
>> [SOUND]
>> Kent C Dodds: Goodness gracious, this thing is not super.

This little plugin for the add-on is great, but it's not always perfect.
>> [SOUND]
>> Kent C Dodds: So once you've made all of your changes, then.
>> Kent C Dodds: These are the commands that you're gonna run. You'll check out a new branch, whatever you wanna call it.
>> Kent C Dodds: Actually first you just go ahead and git rm, or rm -rf.git, or however you do it on Windows.

Just basically delete that branch or that folder. Then you'll check out a new branch called temp. And you can commit all of your stuff.
>> Kent C Dodds: And then you will delete the master branch.
>> Kent C Dodds: And then you'll move the temp branch to master, which will move you to master.

And then you'll push with force.
>> Kent C Dodds: And with that, if you open up your browser to your fork refresh, you should that that you recently made changes, and you should see the name of your library, and all of your changes should be in here. And this is what you're gonna use to set up and publish your module and all that fun stuff.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now