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
[00:00:00]
>> [MUSIC]
[00:00:04]
>> 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.
[00:00:26]
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.
[00:01:01]
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.
[00:01:29]
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.
[00:02:01]
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.
[00:02:25]
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?
[00:02:46]
>> 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.
[00:03:13]
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.
[00:03:46]
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.
[00:04:09]
>> 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.
[00:04:32]
>> 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.
[00:05:06]
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.
[00:05:43]
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.
[00:06:13]
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