filmov
tv
Campus Advisor Training: Module 2.1

Показать описание
Everything we have done thus far has been done locally on our computers, meaning we never had to send information or retrieve information through our network. Git is great locally, but it can be that much better of a tool when we start to upload our code online. Not only can we save our code somewhere other than our personal computers, but we can also promote easy collaboration with the use of GitHub.
In this video you will learn more about GitHub and how to effectively communicate with GitHub using a remote. We will go over how to create a location for your code on GitHub as well as how to setup a remote on your machine so you can communicate with GitHub. We will also learn some new git commands along the way.
Let’s get started
It is common to first create a local repository before interacting with GitHub, so lets do that. First I will create my project directory. From there I will initialize git. Now I will create my README.md. In my README.md I will type the classic “Hello World!” Lets go ahead and commit these changes.
Now, lets take a look at GitHub. GitHub is a platform for software development and collaboration. It will host your repositories and enables collaboration with team members or with other people around the world if you so choose. With that, lets create a repository on GitHub.
After you log in you want to direct your attention to the upper right hand corner. You’ll notice that there is a plus symbol. Let’s click that and select “New Repository.” Here we are greeted with some options. First lets give our repository a name, I am going to name it the same as my project directory, HelloWorld. I’m going to skip the description at this point, I am going to make this repository private and I will not initialize the repository with a README since I already made one locally.
Now, GitHub gives you instructions on how to create a repository as well as how to send or “push” your code to GitHub. Lets go ahead and use the “Quick Setup,” but in the future you are more than welcome to follow the instructions that are given to you if you happen to forget what to do. I’m going to copy the URL given to us because this is the location that GitHub has created for us to essentially store our repository. By using the URL I am using the HTTPS address option, but you have the option to use SSH. If these terms mean nothing to you, that is fine, but I just wanted you to be aware that you have a choice and you can read about them if you are curious in the GitHub docs.
Now in order for us to connect with GitHub we need to create a remote. A Remote allows the transfer of your commits to another machine, in this case one of GitHub’s servers at the URL given to us. Lets head back to the command line to setup our remote connection so that we can send our code to GitHub. We will use the git command remote followed by an argument add, which is then followed by the name we want to call our remote connection. A common convention is to name the remote “origin.” Following that we want to tell our machine the location of our online repo, where GitHub will keep our code, in this case, this is the URL given to us by GitHub. So here is the whole command I want to use. You can read it as the command remote and the argument add tells the local machine to send my commits to the location we specify and we are giving the remote the name of origin. Hit enter. Now we can check to see if that remote is present with the remote command. Git remote, and you will see that our remote origin is present.
Here is the moment you’ve been waiting for. We now want to send our code using our first network request. We can do that by using the git command push. Push updates the remote repository using your local repositories commits. We also want to tell git which branch of commits we want to send to our remote as well as which remote we are using. So the whole command should read git push origin master. So I want to push my commits to my remote, origin, and I want to send the commits from my master branch. Hit enter and I should receive an output that shows my commits have been sent out to GitHub over the network.
Back at the URL that GitHub was holding for us to store our repository, you will see that our README commit is present. We can also see HELLO World in our readme.
Congratulations! You can now push code to a repository for the world to see. You are a step closer to being able to be social with your code. Soon you will have the skills necessary to collaborate with others.
In this video you will learn more about GitHub and how to effectively communicate with GitHub using a remote. We will go over how to create a location for your code on GitHub as well as how to setup a remote on your machine so you can communicate with GitHub. We will also learn some new git commands along the way.
Let’s get started
It is common to first create a local repository before interacting with GitHub, so lets do that. First I will create my project directory. From there I will initialize git. Now I will create my README.md. In my README.md I will type the classic “Hello World!” Lets go ahead and commit these changes.
Now, lets take a look at GitHub. GitHub is a platform for software development and collaboration. It will host your repositories and enables collaboration with team members or with other people around the world if you so choose. With that, lets create a repository on GitHub.
After you log in you want to direct your attention to the upper right hand corner. You’ll notice that there is a plus symbol. Let’s click that and select “New Repository.” Here we are greeted with some options. First lets give our repository a name, I am going to name it the same as my project directory, HelloWorld. I’m going to skip the description at this point, I am going to make this repository private and I will not initialize the repository with a README since I already made one locally.
Now, GitHub gives you instructions on how to create a repository as well as how to send or “push” your code to GitHub. Lets go ahead and use the “Quick Setup,” but in the future you are more than welcome to follow the instructions that are given to you if you happen to forget what to do. I’m going to copy the URL given to us because this is the location that GitHub has created for us to essentially store our repository. By using the URL I am using the HTTPS address option, but you have the option to use SSH. If these terms mean nothing to you, that is fine, but I just wanted you to be aware that you have a choice and you can read about them if you are curious in the GitHub docs.
Now in order for us to connect with GitHub we need to create a remote. A Remote allows the transfer of your commits to another machine, in this case one of GitHub’s servers at the URL given to us. Lets head back to the command line to setup our remote connection so that we can send our code to GitHub. We will use the git command remote followed by an argument add, which is then followed by the name we want to call our remote connection. A common convention is to name the remote “origin.” Following that we want to tell our machine the location of our online repo, where GitHub will keep our code, in this case, this is the URL given to us by GitHub. So here is the whole command I want to use. You can read it as the command remote and the argument add tells the local machine to send my commits to the location we specify and we are giving the remote the name of origin. Hit enter. Now we can check to see if that remote is present with the remote command. Git remote, and you will see that our remote origin is present.
Here is the moment you’ve been waiting for. We now want to send our code using our first network request. We can do that by using the git command push. Push updates the remote repository using your local repositories commits. We also want to tell git which branch of commits we want to send to our remote as well as which remote we are using. So the whole command should read git push origin master. So I want to push my commits to my remote, origin, and I want to send the commits from my master branch. Hit enter and I should receive an output that shows my commits have been sent out to GitHub over the network.
Back at the URL that GitHub was holding for us to store our repository, you will see that our README commit is present. We can also see HELLO World in our readme.
Congratulations! You can now push code to a repository for the world to see. You are a step closer to being able to be social with your code. Soon you will have the skills necessary to collaborate with others.