Git and Github

Git and Github

·

3 min read

  1. What is Git and why is it important?

    Git is a version control tool that helps us to keep track of any file that is uploaded and co-ordinate among multiple users

    Git is very important for several reasons, to point out a few:

    1. For any file added in git, it keeps a record of the author(person who added the file), time and date when the file was added thus making the developers more responsible for their actions

    2. The branching feature of git helps multiple people to work on the same file without worrying about the main code being disturbed. This feature can be very useful in any organisation as there will be multiple developers working on different features

    3. Suppose a code that was running gets crashed due to any new changes made, the previous version can be retrieved without any hassle through a special hash number/commitID that is assigned to each version of the file

    4. Any deleted file can be restored.

  2. What is the difference Between Master Branch and Main Branch?

    Main branch is the default branch that is created when Git is initialised in any local machine. Similarly master is the default branch when you create a new repository on GitHub

  3. Can you explain the difference between Git and GitHub?

    Git is a technology/tool that helps in version control of any file, it will be mostly used on local machines( ex: our computers)

    GitHub is a platform that uses git technology for version control of the code remotely (ie over the internet) thereby coordinating with multiple other users.

    Bitbucket, GitLab, and Atlassian are some of the other platforms that use Git just like GitHub.

  4. What is the difference between local & remote repositories?

    A local repository of git can be created through the git clone command. Any folder can be made a working git repository by initializing git with git init command.

    A remote repository will be created on GitHub and the steps explained above can be followed

  5. How do you create a new repository on GitHub?

    1. Login to GitHub as a user

    2. Click on "+" sign on the top right corner of the home page

    3. Click on "New Repository"

    4. Type the repository name that you wish

    5. Choose if you want the directory to be Public or Private

    6. Check the "Add a README file" checkbox if you wish the repository to be created with a readme file

    7. Scroll down and Click on "Create Repository"

  6. How to clone a repository from Git Hub?

    1. Pass the below command in your local machine where you wish to clone git repository
    git clone <https_url_of_repository>

  1. How to connect local to remote?

    The below command can be used to connect the local machine to remote machine for any given repository

    1. Get your remote git URL from GitHub

    2. Pass the below command to connect remote and local

       git remote add origin <remote_git_url>
      
    3. Check if connection was a success

       git remote -v
      

  1. How to set your user name and email address which will be associated with your commits?

     git config --global user.name <your user name>
     git config --global user.email <your email address>
    

  2. How to create a new file, add some content to it and commit it on git?

  3. How to push your local commits to the repository on GitHub?