Basic Git & GitHub

#90daysdevops

#day08

What is Git?

Git is a version control system that allows you to track changes to files and coordinate work on those files among multiple people. It is commonly used for software development, but it can be used to track changes to any set of files.

With Git, you can keep a record of who made changes to what part of a file, and you can revert back to earlier versions of the file if needed. Git also makes it easy to collaborate with others, as you can share changes and merge the changes made by different people into a single version of a file.

What is GitHub?

GitHub is a code hosting platform for Version Control and collaboration. It lets you and your teammates work together on projects from remote locations. We can perform commits, pull requests, push, create branches, and much more.

Task:

  1. Create a new repository on GitHub and clone it to your local machine

    • Once you have created the repo on GitHub, go to the main page of your repository.

    • on the right side click on the Code button.

    • Copy the Url from the repository.

-

  • open git bash and go inside the directory you want to clone.

    Type git clone, and then paste the URL you copied earlier.

        git clone https://github.com/SUJATA14016/learning-git.git
    
    1. Make some changes to a file in the repository and commit them to the repository using Git.

There are 3 virtual partitions when we are working with git locally.

  • First, we create whatever files we want to create. For example, let's say we create a file name local_file inside the repository.

        touch local_file
    
  • Once we have created the file, we will move it to the staging area.

        git add <file_name>
    
  • Now we use the commit command to move the file from the staging area to the git repo with the "first commit" message.

        git commit -m "first commit"
    
    1. Push the changes back to the repository on GitHub

To push the file on GitHub we will use the following command

     git push origin main

main is the name of the branch we are pushing our file to.

Note: you can use the token in place of the username, asked after using the above command.

Thank you for reading!!

~Sujata Kumari

Great initiative by the #trainwithshubham community.