Placeholder Image

字幕列表 影片播放

  • how everybody, whether you're a longtime programmer or just getting started, you've probably heard that get is one of the most important skills any developer can learn.

  • And I completely agree.

  • This is why I created this video to tell you exactly why I get is so important.

  • Explain how get works and, most importantly, show you everything you need to know.

  • In order to get started, we get in only 20 minutes.

  • Let's first start with what kit is get is a version control system more specifically, a distributed version control system and makes tracking changes to your code overtime.

  • Painless get tracks.

  • Every change has ever been made to the code you tell it to manage unless you easily switch between versions of your code or even undo changes.

  • It also makes it easy for teams of people to work on the same project and even the same file.

  • Since each team member has their own version of the code saved locally on their computer, get also saves.

  • The full version has drowned each team member's computer, which is what makes it a truly distributed version control system.

  • This is all great, but teams need a place to store their code remotely so that all the team members have this central place to save their changes to and pull down other team members changes.

  • This is where get have comes in.

  • Many people get confused when they first formed about get and get help thinking that they're the same thing.

  • However, get Hub is just a website where developers can store their projects for other developers to access.

  • Get on the other hand, as we talked about, is just a version control system for tracking and managing changes to coat.

  • Now that we have a basic understanding of what it is, let's jump into why get is so important and why you should be using it on all of your projects.

  • Imagine this scenario where you're working on a multi part YouTube tutorial to learn the basics of hte e mail.

  • Such was my introduction to HTML course, and you just finished writing all the code for one of the middle videos in this series, only to find out that something you did broke everything without get, you'd have to resort to trying to remember what you change since the previous video and then search there each of those files to determine what exactly is wrong.

  • If you're lucky, you remember all the changes that you made.

  • But most likely you'll have to go through all the files of the project looking for a single mistake with get though this is a trivial problem to solve.

  • Since get tracks all the changes that you make, you would simply have to tell Get to show you all the changes that have occurred since the previous videos code and get will not only show you what files have changed, we'll also assure you the exact changes that have occurred in each file.

  • This bank's finding what went wrong, more enjoyable and quicker get also allows you to change back to previous versions of your coat with a single command.

  • This is extremely useful for any project, since if you deploy your changes to the world and realize later that something major is broken, you can simply tell Get to change back to the previous non broken version of your code without get.

  • This is an impossible task, since nobody will perfect remember all the things that need to be reverted to get back to the previous version.

  • Lastly, get is used by nearly all developers, with Stack overflow reporting that nearly 90% of their 75,000 developers they surveyed used get as their version control system.

  • This means for anyone looking to get a job in programming they will need to know Get.

  • Lastly, you need to ensure that get is installed on your system and configured with your getup account.

  • If you do not already have get installed or do not have get linked with get Hub, then check out my video on the introduction to what Development Right?

  • Cover Installing and setting up.

  • Get with get hub.

  • This will be linked in the description below.

  • Now that you have get properly installed and set up with get hub, we can begin talking about how to use get.

  • The first thing you need to do is initialize.

  • Get in your existing project or clone a remote project from a Web sites such as Get Hub In order to initialize, get in a project that already exists on your computer.

  • Simply run the gettinit grant in the terminal from the full that contains all of your project files.

  • This will add a dot get folder to your project that get well used to track all the changes you made to your project.

  • Get also uses the word repositories or repo for short to describe the entire project being managed by GID.

  • The second option of cloning of repositories could be done by going to get help and either creating a new repositories clone or finding an existing repositories and coffee and the link to clone the project.

  • If you set up, get and get hub using the method from my video, make sure to call me the s S h u r r o and not the http.

  • You are all now with that euro copied type that command get clone into the terminal with the copied euro at the end of the command.

  • This will copy all the code from the depository onto your computer and set up get to track the changes.

  • This also adds the remote repositories to your git config for the project so that when you were ready to push your changes to get home get will already know where to push them too.

  • Now that we have a project set up on our computer, let's talk about the structure of get, get tracks changes through three stages.

  • The working directory, indexed and head.

  • The first stage is the working directory.

  • The working director is simply all the files in the local repositories in their current state.

  • None of the changes in the working directory attractive I get.

  • In order to attract these changes, we first need to add them to the index, which is commonly referred to as staging.

  • This could be done by using the get ad command.

  • This process of adding changes to staging tells get that we want to track all the changes that we have made in our working directory.

  • This still does not make these changes an official version of your code that you can change between, though, in order to add these changes as an official version, we need to scale get to commit these changes from the index to the final stage.

  • The head this tells get the changes are final and requires a message to be saved with the committee.

  • This could be done by using the get commit command.

  • The head is simply the most recently committed version of your code.

  • After committing changes to the head there, saved as a version on our computer, but they are not in our remote depository on get home.

  • In order to get these changes to our remote repositories on get hub, we need to push them to get up using the get push command.

  • If you set up your project using get clone, think it will already know where to push the files to.

  • But if you use to get in it to initialize the new project, then get will need to be told where to push these changes, too.

  • This could be done by creating repositories on get Hub and copying the shur o for cloning.

  • After that has done, you can simply use the git remote at Origin Command with the copy d'Oro at the end of the command, this tells, Get that we have remote repositories called origin at the copy of your own with the remote depository added, you can use the get pushed command to push the changes to the remote repositories and get help.

  • We now are able to create a repositories, make changes to it, save them and push those changes to get home.

  • But what if another one of our team members wants to pull down the changes that we pushed to give her onto their local computer.

  • This is where they get pole command comes in by simply typing the command, get pull into their terminal.

  • All of your changes from get up will be pulled onto their local computer and murdered any of the changes that they have.

  • That is all you need to know about get in order to get started.

  • But there is one more big concept and get called branches.

  • Branches are essentially a copy of the code at a point in time that has its own separate history from the main branch, which is called Master.

  • Imagine you're in a company with two teams and one of the teams is creating feature A of a website and the other team is creating feature B for the same website.

  • These features will have multiple commits in order to be fully completed, but both teams are working out of the master branch.

  • Then whenever the team working on feature A pushes their changes to get hope, the other team will get those changes for feature A.

  • When they try to pull.

  • This will cause problems because now the team working on future be we'll have parts of feature A in their code.

  • This is where branches coming.

  • If the team working on future A creates their own branch off of master and the team working on feature be creates their own branch off of master.

  • Then when the team's pushed the changes to get hope, they will only be pushing their changes to their own branch and not the master branch.

  • This can be done using the command get branch with the name of the branch being created at the end of the command.

  • This will create a new branch, but in order to switch to that branch, they get check out.

  • Command will need to be used with the name of the branch at the end of the command.

  • Since this is such a common operation, there's a parameter you can pass to the checkout command to create a new branch and swap to it.

  • This command is get check out Dash B with the new branch name after the Dash B.

  • Now that both teams have created their own branches and committed all their changes for each feature to their branches, it is time for them to merge these changes back in the master get makes it easy with the get merge Command get merged followed by the branch name that you want to merge will merge all of the changes from that branch into the branch you currently have checked out.

  • If there any conflicts between the two branches give will notify you of these conflicts and let you decide what to do with them before committing the changes, this is finally the end of all you need to know about it.

  • I know it can seem quite daunting, but I'm going to go over a live example of exactly how all these commands work to give you a more hands on experience with how get works.

  • Let's jump into that.

  • Hello, everybody.

  • What's first get started.

  • We're setting up a project on getting The easiest way to do this is to go to get hub, create a new repositories, give it any name you want.

  • We're just gonna call ours, get home test and then click to initialize.

  • This would have read me.

  • This will make us that you can call in the project down to your computer and then click create repositories.

  • And after that's done loaded.

  • No, bring you to your repositories.

  • Page.

  • Here's where you can clone the euro and make sure you use the shur O.

  • If this does clone with http, make sure you clip the button up here which will say, use SS age after you're done with that cooked the Earl, copy it and then go to the folder that you want to copy this into.

  • Once you're here, you can right click this and open the terminal here.

  • And then all you need to do is type Gibbs clone and then paste in the euro.

  • You just copied hitting.

  • Enter for this will copy All of the Cody is inside of that repositories, which includes that Read me we created and bring it into the folder that you are in currently with the terminal.

  • Now to open this just right, click it and open it with visual studio code and we can get started right away.

  • And we see we have a read me and it just says the project name.

  • The read me is important in version control systems such as get hub.

  • Because if you go to get have sight, you can see that inside of your repositories, everything in the read Me will show up on the main page of your depository.

  • There's a great place to put notes and information about what your code does, so that when people come to your depository, they have an easy way to understand it without having to read the actual code.

  • Now that we have that out of the way, let's get started by creating a file on this project.

  • We call it anything.

  • We want such a test on HTML and hit Enter after a little bit, you'll see that this fire will turn green with a little you next to it that stands for untracked.

  • This is because visual studio code integrates perfectly with git.

  • And this tells us that this file, which is green, means that it is new.

  • And since it has a you saying it's untracked, that means we haven't added this file to our get repositories yet.

  • In order to do that, let's open up the terminal by holding control and hitting the till Daiki and typing in get ad.

  • But we'll need to do is add the file name to the end of the get ad.

  • Can't still get what we want to add.

  • So we'll say test dot html.

  • This will add to get the test dot html file to the index of our get repositories.

  • When we hit enter, we'll see that this turns to a instead of you, which means it's been added to the index then.

  • Lastly, if we want to commit this change, we could take a gift commit and then we need to add a message to this.

  • So use Dash M to say that we're adding a message and in quotes put whatever message you want, such as added test file and then hit Enter.

  • And this will add this file to her.

  • Positive it, and you'll see that it is no longer green anymore because it is being tracked by get and is in an actual commit.

  • Now let's say that we want to edit this test file by adding some constant here.

  • Let's just say we're gonna add a paragraph tag and we're gonna put high inside of it.

  • If we say that, we'll see how this will turn yellow or orange, which means that the file has been modified.

  • As you can see by the end, this means that it is different than the current version in Get Hooker and get right now, in order to see what's different between these two files, we can run the get def command.

  • This command will tell us everything that is different in the files that we have in our repositories between the currently version that we have in our working directory and what is the most recent version in the head.

  • If we enter, we'll see that it tells us that this file the test dot HTM o.

  • The only difference is that we added this line high, which is what the Green stands for.

  • It means that has been added.

  • Now let's add that to our repositories.

  • And instead of using the file name, we're going to use a period which tells, Get that we want to add every single file that is in our project.

  • This is an easy way to add a bunch of files at one time, So when we do that, we'll see that our fire will get at it here.

  • And then.

  • If we want to commit that, we do get commit, give it a message, we'll just take a second to commit, hit, enter.

  • And now if I will be added with it.

  • We can make his many changes to his many files as we want in the project, and as soon as we add them, they will all be added into the index.

  • We can even add multiple different times.

  • So let's say, for example, wanna add another P tag here and just say content and then we want to add that So we do get ad, put a period at the end, enter and now let's say we're gonna change, begin before we commit and we want to put an end here so we could get ad for the period at the end.

  • And now that's added to the index as well.

  • So you could do as many as you want in between commits.

  • And now when we say okay, we have all of our changes that we want.

  • We could get commits, sending a message of final commit, and we had enter.

  • We'll see if this file will no longer be marked as modified because is actually in the head of our project.

  • Now that that's out of the way, let's push our changes to get up using the get push command.

  • If we have get and get help configured correctly, this command will automatically push all of our changes toe over a depository.

  • Let's first look at our remote repositories refreshing and see that none of our changes, they're currently here in order to get our changed.

  • Just show up there.

  • We just need to run the get pushed command we hit.

  • Enter.

  • Now this will push all of our changes to a remote depository.

  • And if we head over to refresh, we'll see that these changes air now here, and it shows us the commit measures that we sent with it as well.

  • Now let's go back to here and get started on get branches.

  • The first thing we do is to create a separate branch for a new feature that we're going to create.

  • What say that we're going to create a feature that allows us to take payments.

  • So we're gonna want to create a store.

  • So we use get check out dash B and the name of our branch, which we'll just call store.

  • Now we've transferred over to a separate branch, as you can see in the bottom left hand corner Here, visual studio co.

  • Tells us exactly what branch were on their says store right here.

  • So we know that we're on the store branch?

  • No.

  • What's that?

  • A file in here called store dot HTM.

  • Oh, let's ask him.

  • Content will just add a paragraph tag in here that says this is the store.

  • Now we're going to say that if we add that in and then commit that by saying added store.

  • And now we want to push these changes.

  • Those two could push and we'll see that It says there is no branch currently on get hub for this project because we don't actually have a store branch already on.

  • Get up We need to do is we need to tell get help to create this store branch.

  • In order to do that, all we need to do is copy this command which will configure, get and get hub so that it is able to pull and push to the correct branch Now that get and get how both know that this branch exist was pasted in here and hit.

  • Enter and we'll see that it'll push our changes up to our remote repositories.

  • Now let's go over our depository.

  • Refresh it and you see that these pain just don't actually show up.

  • It's because it's on a separate branches you could see here.

  • We're on Branch Master.

  • And if we switch to the store branch, you'll see that now our store changes show up here we switch back to master, you'll see that they're no longer there.

  • But we want those changes to be in master because now our story is complete.

  • In order to do that, we need to switch back to the master branch by calling get check out Master, which now switches us back to the master branch.

  • And we can see that inbound the bottom left hand visual studio code.

  • Or if you just get status hit enter, it'll tell you exactly what branch you're on.

  • So now we need to run the merge plan to merge our changes from our store branch into our master branch.

  • So we type in, get emerged which will tell, get hub or tell get to merge.

  • Whatever branch we mentioned into the Met branch that were on which is the master branch.

  • So if we type get merged in the name of the branch which is store hit, enter all the changes from the store branch will be merged into our master bench, and as you can see, the store dot html pages showed up.

  • So now if we run, get push.

  • In order to update our remote repositories with our local changes and hit enter, you'll see that now when we go to a remote repositories and refresh it that the store pages now there.

  • This is because the merge command automatically adds and commits the files with a message that says, That is added the store.

  • Now if we go back, what happens if there's emerge?

  • Can foot the what say we have?

  • This is the store and in our master branch we change this to say, this is the store too.

  • And if we had that and if we commit that just any message and then we switch back to our store branch, which we could do it get check out store.

  • Now we're back on the store branch, and as you can see this updated to be, this is the store.

  • Since we do not actually have those changes for master on this branch, let's say we change this to be this is the store one save it.

  • Add those changes and commit them, any message will work.

  • And now let's switch back to the master branch.

  • So now what we want to do is we want to merge those changes from our store branch into our master branch just like before, by calling Get marriage store, we'll see right here.

  • It tells us that there is a conflict and it is saying that inside of the store dot html file, there's a merge conflict and visual studio code will very nicely highlight this for you.

  • But get also will add in thes less than signs followed by head as well as the greater than science, followed by a store telling us that the head is our current branch.

  • So everything between these equal signs and these lessons signs is what is on our current branch and everything between the great and signs and the equal of men.

  • Signs wishes from the store branch will show up here, and it's telling us that get is not smart enough to know which change it wants to add in.

  • It is saying that we need to figure out which change should be saved, so all you need to do in orderto side on.

  • What change is going to be made is you look at it and say OK, what we want.

  • This is the store to we don't want.

  • This is a store one.

  • So we delete This is the store one as well as all of these signs that get crates.

  • So if we like that, do with these Sure, we got it all set up with no extra line breaks in there.

  • Save it.

  • And now we have decided on what conflict we're going to resolve from.

  • We decided that we want to take the changes from the master branch and none of the changes from the store branch now we need to do is add that file by calling Dad period after it and then we could just called get commit.

  • This is because it will automatically generate commit message for us if we hit enter.

  • As you can see, it opens up on visual studio code editor, which is something that if you watched my video on studying up, getting get hub was an option that I gave you as opposed to use in the terminal.

  • Once you have gotten in here, we see that get has already created a message for us.

  • All we need to do is save this file and close it, and it will automatically create that merge for us.

  • Now, if we get pushed, set it up to a remote repositories.

  • Well, now, see that when we go to our remote repositories, refresh it.

  • We open up our story by east.

  • You know, Paige, we have This is store too, Which is exactly what we wanted.

  • You're here now in order to simulate having multiple people working on the same project.

  • I'm going to re clone this project.

  • Copy the URL here.

  • I'm just going to clone it onto my desktop.

  • It's about time we get clone command fall about that euro it entered.

  • And now little clone that onto my desktop and you'll see that if we open this up using visual studio code, we have all the changes from before.

  • Now it's a paternal.

  • And imagine that we're now a different developer working on this project.

  • Unless they were coming here, we want to add another line in here that says the real end.

  • Save that.

  • What's on then?

  • With a message that says John's changes because we're going to pretending that we're John and let's push that up to the depository on.

  • There we go.

  • Now.

  • If we go over tire repositories, refresh it.

  • You see that this test has John's changes of the into.

  • But if we go to our original project, this one that is open inside of knock desktop, this is the original one that we created.

  • You'll see that when we go to the test, John's changes there.

  • Not here.

  • This is because we need to use the get pull command to update our local repositories from the remote repositories.

  • All we do typing get whole hit, enter, and it'll pull down all of the changes from the remote repositories for the branch that you are on.

  • And since we're in the master branch, it pulled down the changes from the master bench, which is where John added his changes.

  • That about sums up everything that you need to know about.

  • Get the whole process goes first, create a project on get hub next clone that project down to your local computer at any amount of code and changes that you want using.

  • They get ad command, and once you finalize those changes into a coherent version used the commit command to commit those changes to get.

  • Then, lastly, after you've done all of the Addy and all the committing that you need to do for a particular feature or project than you used to get pushed command to push those changes back up to get him.

  • We also need to use branches in between there to be ableto create new branches for certain features so that you do not bring different features into each other instead of using just one branch, the Master branch, for example, where all the features would be.

  • You now have separate branches for each of your features so that your code does not get mixed together.

  • And then, at the end, emergency back into master.

  • Since master is your overall branch, that describes the current state of where your project is, and that's all there is to it.

  • If you like the video, please remember to leave it like and subscribe for more content.

  • And if you want to see a more in depth tutorial involving some of the features of get that I was not able to cover in this video, please make sure to comment down below, letting me know.

how everybody, whether you're a longtime programmer or just getting started, you've probably heard that get is one of the most important skills any developer can learn.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

A2 初級

20分鐘學會Git (Learn Git in 20 Minutes)

  • 5 1
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字