Git repository

In this article we will see steps for creating a git repository local and then pushing it to remote repository.

Step 1. Download git version control software from https://git-scm.com/downloads

GIT Download

Double click on downloaded exe and install it with default settings.

GIT Installation

Step 2. Create a project

I have created an ASP.Net Core project using Visual Studio 2019. You can create your own project using your preferred SDK or IDE. Below screenshot shows my project files.

Project Files

Step 3. Git init and commit

Open command prompt and navigate to root folder of your project. Use below command to initialize local git repository.

git init

After init , use below command:

git add .

After add command, use below command to commit files in local repository:

git commit -m "First commit"

Step 4: Push Changes to Remote Repository

Create account on GitHub, visit URL https://github.com. Login with your credentials in GitHub.

Create new repository in GitHub by clicking on ‘New’ button as shown in below image:

New Repository Button

Fill repository name and description and create repository:

Create new repository

Below is the GitHub repository page:

GitHub Repository

Please note HTTPS URL of git repository, now we will push our local git repository to GitHub repository. Open command prompt again and navigate to root folder of project and use below commands:

git remote add origin https://github.com/vijendra-ksh/ASP.NetCoreMVC_Project_Part1.git

git push -u origin master

Push local repository to GitHub

Now local changes are pushed to GitHub repository. Below screenshot shows GitHub repository after pushing local changes:

GitHub Repository After push

Later when we make changes in project files then we need to commit in local repository first and after that we can use push command to update remote GitHub repository.

Below are the commands in sequence to commit changes and push in remote repository:

git add .
git commit -m "changing program file"
git push

In this article we have seen git commands to commit and push in repository.

Please like our Facebook page for getting updates about new articles :
https://www.facebook.com/logixn

Leave a Comment

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