Introduction to Git and Commands

01. Introduction to Git

Git is officially defined as a distributed (VCS) version Control System.

It's a system that monitors changes in our project files over time. It allows us to record project changes at any time and return to a selected version of the tracked files. This method is often utilized by many to figure efficiently and collaborate on team projects, where each developer can distribute their own version of the project on their computer. Later, these individual versions of the project are also merged to suit the most version of the project.

Basically, it's a hugely popular tool for coordinating parallel work and managing projects between individuals and groups. Needless to mention, knowing the way to use Git may be an important skill for any developer today - it's definitely an excellent addition to your resume!

The version control system is the management of changes to document changes in computer programs, large websites, and other collections of information.

There are  two version control system in Github

  • The local version control system
  • Centralized &Distributed Version Control Systems          
The local version control system
  • Copy the file into another directory
  • it is so simple and also incredibly error-prone  
        


Centralized & Distributed Version Control Systems 

The next major issue that individuals encounter is that they have to collaborate with developers on other systems. Centralized version control systems were developed to deal with these issues. Examples of these systems are CVS, Subversion, and Perforce. Here there is one server that owns all the files and different servers that scan the files from that central location.

 


02. Repository 

A git store is a .git / folder within a project. This repository has the ability to store relevant data for your project. You can easily create this repository. The Github repository is the container that everything related to your project files. The code view is where you will find the repository these files may contain the project code documentation and other important files we also call this view the root of the project any changes to these files will be tracked via getting version control the readme is a special file that we recommend all repositories contain GitHub. GitHub looks for this file and helpful displays. In the below repository the readme should explain the project and point readers to helpful information within the projects, 

A few Operations & Commands

03. Initializing a repository

Create a new repository and start using your project with git. Go to the main folder of your project. Then use the cmd command in the path above, open the terminal and type the following command.

        git init


04. Checking the status

Located in your project folder, you can type the following command to check the status of your created repository.

       git status


05. Adding the file 

Type the following command to add git to all the files in your created project folder.

        git add .


06. Making Commits

commit is a short note applied to your code at a specific time. Type the following command to enter all the files here.

    git commit -m "Commit message"


07. Commit history

To view all the commits on your created project, you can use the following command.

    git log


08. Push the repository files

To push all the project files you have created, you can push all the files by pasting the link to the repository as your creation to the terminal. The following command can be used:

 git remote add origin youlink

 git push -u origin master


09. Ignore files

You can create a file named ".gitignore" in the project folder you created to override the files your project does not need. You can add files that you do not want to monitor.


10. Branches

A branch can be defined as a single timeline of your project. When you start a store and start creating commits, they are saved to the master branch. We have the ability to create, modify, merge and delete branches in this store. The following commands can be used for that.


  •  Create a branch


   git branch <new-branch-name>

  •  Change a branch

   git checkout <branch-name>

  • Merage a branch


   git merge <branch-name>

  •  Delete a branch


   git branch -d <branch-name>



Comments

Popular posts from this blog

HTTP Methods

KoaJS in NodeJS

S.O.L.I.D Principles