Quick steps for beginners to use to push code to GitHub
You are new to coding and want to make your first commit and push the code to from VScode to GitHub. If you are looking for something like this, I won’t waste your time explaining what GIT and GitHub are.
- Open Visual Studio.
- Open the Folder you want to push to Github. In simpler words, PUSH is like a UPLOAD button.
- Keeping the Folder that you want to push open click on the Terminal menu from the Top menu bar.
The terminal will look like this. So please don’t panic there are some simpler commands of git which we will use here and you will get used to it.
Open GitHub now and SIGN IN to your account. If you haven’t signed up please go and sign up first.
After signing up your profile will look something like this, I have customized it a little so don’t focus on that.
Click on the Repositories tab on the left side of your screen. Check the below image, this window will appear.
Repositories are like the C drive or D drives on your computer, these drives are collections of different folders, right? Similar to that Repositories or Repo in short are like Drive which will collect all those codes file that you will wish to upload. Cool?
Click the “New” button on the right-hand side of the screen
It will open a new window where you have to enter your repo name.
Enter any name that you want to give to your repo. I have entered “forarticle”. By default your repo would be public, which means you have an option to keep your repo either public or private. So whatever way you want your repo to be, select one and leave other fields empty and then click on the “Create repository” button.
A repo with this name would be created.
A new window will open like this (check the below image), keep it open. These are the commands you will have to use for connecting your local environment to Github. The local environment here means the system that you are using right now for coding.
Pushing the Code
For pushing codes you have to come on the VSCode again, for e.g., this is the code I have kept to push. (see below image 👇)
Now as we have already opened the Terminal in the first steps, we have to enter certain commands. (refer to the below image for that)
Note: I am not going into detail about what these commands do. I am going to make a separate article for that.
- git init will initialize an empty git.
2. git branch will help you create a branch, here the name of the branch is “main”.
git remote add origin will help you add the origin, destination location for the push
git add . will track down all the files and make these files ready to be pushed keeping it in the staging.
3. git commit will commit saying I am ready with my files with my all changes.
check the git commit result
4. git push will upload everything onto the destination defined in the command shown in the above image 👆.
The uploaded files in your GitHub will be displayed like the below image 👇
That’s it for the code push. In the next blog, I will post in detail about Git and its commands. In the meantime, if you still want to check about commands check this link:-