How Push to Github from Command Prompt/Terminal (2024 Update)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to this video guys let's see how we can push our project or push code from our local machine to GitHub using command line or terminal first go to your project directory so I have this one file here and right click and click on open in terminal or you can hold shift and right click and you will give this you will get this option that says open git bash here so both of these opening terminal or open git bash will work here now to see this option open git bash here you need to have git installed now you cannot do this without installing git so if you don't have git installed yet check the link in the description it will show you how you can install git okay so now let's open command promp by right clicking and clicking on opening terminal or click here in the address bar and type CMD hit enter and as you can see command pumpt is now open and it is open inside your project okay now we need to type this command get in it now what this does is as you can read it initializes empty G repository so and now we have this git repository so you can see here dogit is now created and now we can do all the git stuff in this project and we can push it to GitHub so first we need to add all the files to git repository the command for that is git add dot hit enter and every project sorry every file inside your folder will be added to git now you can add just names here like get add and fil name. dxt and so on but if you have a lot of files it will take a lot of time so we can just add everything by doing this get add and period sign after this we need to commit now what is commit now this commit is what you need to do to make sure which changes are pushed to GitHub so for now let's say I just do initial initial commit right and I have not done any change right now and now we are ready to push so what you can do is get push push and push where after get push you need to enter your url where you need to push right so you cannot do that instead of URL what we need to do is we need to go to GitHub and first let's create a new repository to GitHub also so you cannot push different projects to the same repository you need to have different repositories for different projects like these so what you can do is click on new and you can give this a name so let's call this web project and can keep either private or public selected so I'll just have this public repository and I can click on create repository so once the repository is created now this is the URL that you need right so I'll copy this go back to my terminal or command prompt and we need to enter this command that is get remote add origin so this is adding origin now origin is where we need to push right so so what is the URL of the origin this is it and hit enter so we have now added origin now what we can do is get push origin and we need to enter a branch here and to which branch we push all right so we want to push to master Branch or you can have any other branch that you want hit enter and as you can see we have now pushed to master Branch so if I reload this as you can see index HTML is here and this is the initial comment now if I click here as you can see there is no nothing here because I have written no code here now what is the meaning of Commit This is what I'll show you right now so if I right click here and click on open with and notepad and let's write change one and save this and go back to my terminal and let's say we want to push again right if I enter change a should be pushed but it is not what is shown it's uh everything is up to dat is shown and if I reload this change a will not come here so this is why we need to commit commit make sure that your changes are pushed so if we have multiple changes and there are some changes that we have not committed so uncommitted changes are not pushed so I can write get commit DM and then add this message my new change and again we need to add this so I'll add this get add Dot and everything will be added commit and as you can see one file is changed and now I can do get push or region master and if I reload again as you can see change one is now here so this is how you can initialize G repository and push to GitHub if you have any questions let me know in the comments below
Info
Channel: The Code City
Views: 346
Rating: undefined out of 5
Keywords: how to push to github from command prompt, push to github from command prompt, push to github, push to github from terminal, commit and push using command prompt
Id: Kz9j3oU3gVI
Channel Id: undefined
Length: 4min 53sec (293 seconds)
Published: Tue Apr 09 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.