Create a Repository and Push Code To Github First Time

To start the process of Create a Repository & Push Code To GitHub First Time, first I want to tell you some more about GitHub and git version control. Git is mainly used for the collaboration of the projects and track the file changes. Before we start, we need 2 important things first,

Create a New Repository on GitHub

After create an account on GitHub, click to the (+) icon then click on “New repository” to create a new repository.

create a new repository on GitHub
create a new repository on GitHub

After click on the “New repository” link, you got the form where you have to fill out the name of the repo, access permission like a public or private and add a readme file to set the details about your project.

Create Repository on GitHub
Create Repository on GitHub

After that you got your new repository which look like this,

New Repo GitHub
New Repo GitHub

Push Code To GitHub First Time

According to the above image you have to copy the repository link by clicking on the green “Code” icon. After copy the link, open git bash on your windows machine and run the git clone command.

Command: git clone https://github.com/bikashkrpanda/TestRepo.git

Clone Repo GitHub
Clone Repo GitHub

When you clone any repo the first time you got this authentication prompt, click on the sign-in button and authenticate by entering the user ID and password then the clone will be successful.

Cloning Repository Success
Cloning Repository Success

After cloning the repo you got the directory like this.

Main Points to Push Code To GitHub First Time

  1. Open the directory where you clone the Repository.
  2. Copy the files which you want to push.
  3. Paste those files on the repo directory which is created at the time of cloning.
  4. Then go to the Git Bash and enter the same directory by cd command.

After putting the files, on my case I paste one test file on it.

Added a file in New Repo
Added a file in New Repo

Now we check file using Git Bash and start pushing files using git commands.

Here are all the steps to push files on GitHub,

  • Check Repo Status: git status (To check modified or newly added files)
  • Add Files: git add fileOne.php fileTwo.php (Add modified or newly added files)
  • Git Commit: git commit -m "Write message about files"
  • Check current branch: git branch
  • Push files on a branch: git push origin yourBranchName
Complete GitHub commit process
Complete GitHub commit process
Push files on GitHub
Push files on GitHub

After complete the above process the final repository look like this.

Using same command you can update or add new files on your repository.

Here is complete visual guide to Create a Repository and Push Code To GitHub First Time. If you have facing any issue with the above steps please comment below.

Also Check:

Happy Coding..!

Was this article helpful?
YesNo

By Bikash

My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH. I am a web Programmer by profession and working on more than 50 projects to date. Currently I am working on the web-based project and all the CMS and frameworks which are based on PHP.

6 thoughts on “Create Repository & Push Code To GitHub First Time”

Leave a Reply

Your email address will not be published. Required fields are marked *