Day  05 - Git Basic Commands

Day 05 - Git Basic Commands


Introduction

Git is a popular version control system used by developers to manage their source code. It was created by Linus Torvalds in 2005 to help maintain the Linux kernel. Since then, it has become one of the most widely used version control systems in the world, with developers and companies relying on it to manage their codebases. In this blog post, we will discuss the basics commands of Git and how to get started with it.

Creating a Git Repository

Before we can start using Git, we need to create a Git repository. A Git repository is a directory where Git will store all the versions of your source code. To create a new Git repository, navigate to the directory where you want to store your code and run the following command:

git init
        

This will create a new Git repository in the current directory.

Adding and Committing Changes

Once you have a Git repository, you can start adding and committing changes to it. To add a file to the repository, use the following command:

git add <file_name>
        

This will add the file to the staging area, which is where Git tracks changes that you want to commit. Once you have added all the files that you want to commit, you can commit them using the following command:

git commit -m "Commit message"
        

This will create a new commit with the changes you have made. It is important to add a descriptive commit message that explains what changes you have made.

Pushing to remote repository

The git push command is used to transfer or push the commit, which is made on a local branch in your computer to a remote repository like GitHub. The command used for pushing to remote repository is given below.

git push 'remote_name' 'branch_name'        


Conclusion

Git is a powerful tool that is essential for any developer who wants to manage their source code effectively. In this blog post, we have covered the basic commands of Git, including creating a repository, adding and committing changes, and pushing code to remote repository. With these tools, you can manage your codebase more efficiently and collaborate with other developers more effectively.

To view or add a comment, sign in

More articles by Sachin Benny

  • Dear 3rd Standard Me, Computers Break – And It’s Almost Always Us

    It All Started in 3rd Standard – The Day I Met My First Computer I still remember it vividly—the day a big box entered…

    1 Comment
  • Day 04 - Git 101

    Introduction Collaboration is one of the important factor that needs to be achieved in the DevOps process. Version…

  • Day 03 - DevOps Tools

    Introduction I planned to learn all the DevOps tools during the journey of #100DaysOfDevOps.To be honest, while…

  • Day-02 - DevOps Phases

    Introduction DevOps is a methodology in the software development and IT industry. Used as a set of practices and tools,…

    1 Comment
  • Day-01 - DevOps 101

    Introduction In today's fast-paced world, businesses need to deliver high-quality software products at a rapid pace to…

    2 Comments
  • IaaS,PaaS,SaaS ft.Cake Delivery

    Introduction As a cloud aspirant, you might have heard the terms IaaS, PaaS, SaaS in the initial stages of your…

    2 Comments
  • Why do we need cloud?

    The first rule of management is delegation.Don't try and do everything yourself, because you can't Anthea Turner…

    2 Comments
  • What is cloud to a non-techie ?

    Introduction Have you ever tried to explain a technical concept to a non technical person? As a cloud engineer,I had…

    5 Comments

Others also viewed

Explore content categories