DEV Community

Cover image for Git Introduction.
Kumar Shubham
Kumar Shubham

Posted on

Git Introduction.

If you are into the programming world, you might have heard about git. Its complicated terms easily overwhelm the newcomers, this post is for those newcomers. Letโ€™s start.

Why Git?

When we are working in a team, code sharing is always a problem, we donโ€™t know who implemented what features and whose changes break the code. Here, Git comes as a savior.

What is Git?

Git is a distributed version control system(VCS). It is not the only Version Control System But the most famous one.
Git allows us to see changes made to code in past and also who made it. If there are any problems with the code then we can revert to an earlier version of our code too. Isnโ€™t it great?? We can also upload our code to site like Github and Gitbasket. Our team members can clone or fork it from there and start to work simultaneously by creating a new branch.

Clone, fork, and branch might be led you to think that git is complicated but trust me it is not that complicated. Once you start learning step by step all will become clear.

In this blog, Iโ€™m going to teach you some basics git commands, enough to get you started. But first, install Git in your system.

Installation.

To download and install git in your system, click here and choose Git version for your OS and then follow the required installation steps.

After installing git you are ready to run git in your system.

Most Used Git Command.

  1. git init
    This command will make your repository(just a fancy name for folder) into a git repository.

  2. git status
    This command will show the status of your git repository like whether the files are tracked, staged, or not.

  3. git add .
    This command will stage all unchanged files.

  4. git commit -m "message"
    This command will commit your staged files and a version of your program is created. In the future, you can always revert to this version of your code(more on that later).
    Replace the message with a meaningful text. It should be small and descriptive. Some common convention of writing commit messages are--

   * feat - a new feature
   * fix - a bug fix
   * docs - changes in documentation
   * style - everything related to styling
   * refactor - code changes that neither fixes a bug or adds a feature
   * test - everything related to testing
   * chore - updating build tasks, package manager configs, etc.
Enter fullscreen mode Exit fullscreen mode

5 . git add < filename >
To stage, any particular file run this command and then run the commit command.

6 . git log
This command allows us to view information about the previous commit.

Top comments (0)