Steps For Configuring Git 📥📤 With Details

Introduction

In a previous article, I described in detail Git and GitHub and how they perform the roles of source code management and version controlling systems. Also, I described how the developers can utilize Git and GitHub in their day-to-day real-time work.

In this article, I will describe below-mentioned points below in detail.

  1. Steps to configure git on Windows.
  2. What are git clone and pull commands and how to use them?
  3. What are public and private repositories?
  4. Steps to create public and private repositories and their differences.

Note. Before going through this session, please visit my below-mentioned session related to Git and GitHub.

Introduction To Git

Let's know about Public And Private repositories

So, I need to create a new repository calledSecondRepo as mentioned in the below image. As per the below image, the red highlighted marks should be the proper inputs as mentioned by me.

Public

There are two types of repositories called public repository and private repository as mentioned in the below image.

New repository

Public Repository

Anyone can see that repository. There is no need to get an authorized or authenticated user to this GitHub account but you will not be modify the code. To access or modify code, You have to give that user proper access to your GitHub account.

Private Repository

Here you have to choose who has to see and modify the code of this repository. If I choose the private repository then I have to select the users and give them proper access like read and update access.

Now you can see the new repository named SecondRepo is created successfully as mentioned in the below screenshot.

Code

Let's know about the Git clone

So in my repository named SecondRepo whatever files are present here I need to take these files to my local repository. For this, I need to clone this. To clone this you need to select the code tab and there are various ways we can clone with and these are HTTPS, SSH, and GitHub CLI as mentioned in the below image.

 Git clone

So as of now I can use a clone type called HTTPS and using this URL under the HTTPS clone type I can take the files available in the SecondRepo repository to my local repository. So, for this I need to install an application called Git to configure this HTTPS URL because that is related to Git and GitHub.

To get this Git application just type in the search bar or Google it for Git for Windows. So, you can see a related interface as mentioned below.

 Git application

I click here 64-bit Git for Windows Setup as per my system configuration and it will start downloading. I installed it on my local machine and made sure Git is installed on my machine or not, to know this you just right-click on the desktop and you can see the interface with a few Git options as below image.

  • Git GUI Here
  • Git Bash Here
    Git GUI

That means Git is installed properly in my local machine. Now I need to upload my project files to the SecondRepo repository under Add File >> Upload Files as per the mentioned below image.

 Upload Files

After that you get an interface as mentioned below and click on choose your files.

Choose your files

Here I added one DateDetails.cs file and after successful upload, the interface is shown below.

DateDetails

If you click on the date details.cs file then you can see the entire code in GitHub as below image.

Entire code

The next step is to go to the Code tab and click on clone type i.e. HTTPS and copy the HTTPS URL as mentioned in the below image.

HTTPS

The next step is, I create a new folder called MyGitRepo on my local machine. Go to this folder right-click inside this folder and click on the Git Bash Here option as mentioned in the below image.

Then you can see an interface of Git as mentioned in the below image.

Interface of Git

After that, you mention your HTTPS URL with the git clone command. Here git clone is the Git command. Our system can't recognize the git clone command by default and that's why I installed Git in my local machine. Check the below image.

The command is

git clone https://github.com/satyaCsgithub/SecondRepo.git

Command

After then my Git started cloning the files in the SecondRepo repository to my local machine. Check the below image.

 SecondRepo

Also, You can check in the local machine there is a new folder created same as the SecondRepo repository name, and the files available in that repository are cloned successfully into my local machine. Check the below image.

 Local machine

To get the list of files and folders in my local machine using the Git command "ls" as mentioned below. Here ls is the command that gives the list of files and directories.

 Git command

To check the details of the file in that SecondRepo folder check the below command as mentioned below.

File

Git Clone

It is the git command that is used to clone the files for the first time from our local machine.

Let's understand in details with scenario

Here one developer created one new file under the SecondRepo repository in GitHub and then clicked on the Commit new file button to save the changes. The file name is MyFile1.cs and the content of this file is mentioned below.

 Repository in GitHub

Here you can see the newly created file as mentioned below.

 Created file

Let's know about the Git pull

Now I want to get this new file named MyFile1.cs to my local machine. For this I use a git command called git pull. This command will start pulling that new file from the SecondRepo repository to my local machine. Check the below image.

The command is: git pull

 Git pull

If you check the local machine then you can see that new file as mentioned below.

 Machine

You can check by command as below image.

 Check

Now I want to print the content of this new file called MyFile1.cs. The command is cat MyFile1.cs. Here you can see the same content I have made changes in the GitHub account the same content is available now on my local machine.

 GitHub account

let's update the same file with new content by clicking on the edit option. Added one line code as highlighted in the below image and then clicked on the Commit changes button.

 Changes button

Now my new file is updated with new changes as mentioned below.

New changes

Now I want to get the latest changes to my local using the git pull command and print the latest content using the cat MyFile1.cs command as below image.

In this way, We can get new files and updated files with new changes using the git pull command from the GitHub repo to Local Git.

Difference between Git clone and Git pull
 

Git Clone

  • It used to get files for the first time from the GitHub repo to the Local Machine
  • It is used only once

Git Pull

  • It is used to get the latest changes or files from the GitHub repo to the local Git
  • It can be used multiple times

Let's Understand Git Flow Using Diagram

Git Flow

Here GitHub is the account and there are two repositories called FirstRepo and SecondRepo. So, I want to get files from the FirstRepo repository to my local git which is available on my local machine. The git is installed on the same machine as I described earlier. Here for getting code the first time I used a command called git clone to get files from the remote repository to my local repository. There is a repository called .git is created and this is nothing but a local repository in my as per the below image.

FirstRepo

The first time after cloning, This .git folder is in a hidden format. To make it visible just make the setting as shown in the below image.

Hidden format

Understanding Public and Private repositories in depth

Here I will check my public repository SecondRepo in another browser without signing in. Here everyone can see those files even without signing in or without any authentication and authorization as shown in the below image.

Signup

Here edit link is disabled so that the user can't change it without signing in and for this special permission is required with Signed In as shown in the below image.

Edit link

Now I want to create a private repository calledMyThirdPrivateRepo as shown in the below image and let's see what happens.

Private

After then you can see the interface as shown below.

Interface

Here I will check my private repository MyThirdPrivateRepo in another browser without signing in. Here you got a page not found message.

 Browser

If one user called abc also signed in and wants to see the files present in that private repository but the user can't access that private repository. For this, the admin of that private repository which means who created that private repository gives permission to that abc user. Those permissions are for seeing the repository the admin will give the read permission to the ABC user and for updating the changes the admin will give write permission to the ABC user.

Summary

In this write-up, we have learned the below details.

  • Steps to configure git on Windows.
  • What are git clone and pull commands and how to use them?
  • What are public and private repositories?
  • Steps to create public and private repositories and their differences.


Similar Articles