How to Push Code to Github from Visual Studio Code (2023)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
first go to your browser and go to github.com click on sign up and enter your email I write mail the code city gmail.com click on continue now let's create a password cck on continue again let's enter a username click on Type n or Y anything is fine click continue now there's a puzzle click on verify and now this puzzle might change so I just have to use my arrows keys to point this deer to the direction that the arrow is uh the hand is pointing so it's this direction now click submit now click on create account you'll be sent a code to the email that you entered so go to Gmail and here's the code copy it paste the code here and your account is ready now enter these things I'll just enter just me and na here click on continue you can leave these things unchecked you can use this later continue again and we will choose free plan for now and finally our GitHub is ready so this is the GitHub dashboard or the GitHub homepage once we have your account let's see how we can push code to GitHub first we need to create a repository in GitHub right so let's click on create repository and just give it a name test repo is what I'll call it you can choose to write a description also you can make the Repository public or private if you have made a repository public it will be accessible by using the GitHub URL if you have made it private it will only be visible to you and whoever else you give permission to so let's make it public for now and no need to change anything else just click on create repository so our repository is ready now whatever code we do on our computer can be push to this repository you can think of this repository as like a bucket so whatever you do you push it to this bucket now let's go ahead and open our Visual Studio code so that we can push code from Visual Studio to this repository now I don't have any project open here if you have a project it's fine but for now I will just open a folder let's say uh there's a new project and let's call this new project if you have a project you can open that folder but I just created this new folder so let me create a file that we will push to GitHub so let's say test code.txt and you can have anything here you can have your python code you can have your Java code you can have your PHP code JavaScript whatever for now let me just write code goes here now if you already have your project here no need to do anything now once you are ready to push to GitHub what you need to do is first we need to initialize a git repository inside this project itself so you cannot push anything here the project that you push to git needs to be a git repository in itself so let's see how we can do that now go to terminal and click on new terminal now this terminal will open up what you need to do is initialize good repository inside this project so how to do that get init this is the command now as you can see initialize G repository message will be shown now if it shows something like command git is not found that means that git might not be installed in your PC so check the link in the description to see how you can install git okay now git is initialized now we need to add which files we want to push to our remote repository so generally you want to push most of the files right so how to select all the files to push to remote repository you just do get add and this period so this means add all the files so all the files will be pushed to GitHub repository now the files have selected for tracking now what you need to do is you need to commit the changes only the changes that are committed are pushed to get a reposit so let's say you have a few codes that that are right and few code that are correct so if you had committed after your code was working what uh then only those changes will be pushed not the newer changes changes after the commit are not pushed so how to commit get permit and then you write a message that's say F feature sign up working all right this is the commit and now we have a local G repository now what we have here in GitHub is the exact replica of what we have in our local machine not exactly replica let's say it's a a server or cloud storage of what we have here now how to push from here so first our project needs to know the URL right if it does not know the URL it will not know where to push so let's copy this URL or you can copy from just click this to copy and you write this command get remote add origin and paste that URL now this URL is added so now you can push because we have initialized the get repository we had added all the files that are needed to be pushed and we have committed so everything before the comit will be pushed and finally we have added the origin where we want to push so the command to push is get push origin and here we need to write the branch to which we want to to which we want to push by default there's no branches here so we will just push to master now branch is like something where you put different features probably there can be a master branch which has your live or production code there can be a Dev Branch where you just push development code or test code so you can create multiple branches now you need to sign up so that GitHub knows who is pushing so click on sign in with your browser and just click authorize get your system now sign up is complete if you go back here as you can see we have pushed to our remote repository now let's go back to our repository and reload and as you can see the test do code is here if you click on on this the code goes here is here so this is how you can push from vs code now as you can see we have pushed to master Branch if you want to change Branch if you want to push to other Branch what you can do is let's say get check out and let's say we can name this Branch test Branch right so now okay so test brch is not there so that's why we are not able to check out to this so if it is not existing just add this and test Branch will be created now if you check get status it will tell you on test Branch nothing to commit working to clean because there are no changes so if we just change something here let's test stuff and we check the status it will show this file is modified commit the changes or something so let's just commit get commit and let's write testing this feature right now check your status again it will show you no changes nothing is modified we have everything is committed now let's push get push origin instead of Master this time we are pushing to test Dash Branch so now pushing is complete let's go back here and let's go back to our Repository and in the master Branch nothing has changed because we just made the change in our test Branch so let's go back and if you select test Branch from here and click on this as you can see the new feature is here so this is how you can push to GitHub from Visual Studio code and create branches and check the status and all that stuff so I hope this video helped you if you have any questions let me know in the comments below
Info
Channel: The Code City
Views: 27,278
Rating: undefined out of 5
Keywords: how to push code to github from visual studio code, push code to github, push code to github from vscode, vscode github, vscode github tutorial, vscode github push
Id: jT9QEUOX00w
Channel Id: undefined
Length: 8min 59sec (539 seconds)
Published: Thu Nov 23 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.