Explain about Git and GitHub

What is Git?

Git is an open-source distributed version control system designed to handle any project, small or large, nimbly and efficiently.

Git was developed by Linus Torvalds to help manage Linux kernel development originally.

Git is a version control system. Git is used to keep track of code changes.

Developers use Git through a command-line interface or GUI tools to perform actions like creating a repository, staging changes, committing modifications, branching (creating separate lines of development), merging branches, and collaborating with others by pushing and pulling changes to and from remote repositories. It's widely adopted due to its speed, flexibility, and efficient branching and merging capabilities. Platforms like GitHub, GitLab, and Bitbucket provide hosting services for Git repositories, enhancing collaboration among developers.

What is GitHub?

GitHub is a platform used for version control and collaborative coding. It allows developers to store and manage their projects using Git, a distributed version control system. Developers can host their code repositories on GitHub, making it easier to collaborate with others, track changes, manage different versions of their code, and work on projects together. It's widely used in the software development community for open-source projects, team collaborations, and individual projects alike.

Uses of GIT

  1. Monitoring code alterations in files.
  2. Documenting contributors responsible for code changes.
  3. Logging timestamps for code modifications.
  4. Offering a comprehensive project history.
  5. Facilitating collaboration on shared code across files.
  6. Make it easy for related programmers in the world to remotely work together.

GIT Installation

  1. Download the Git from the following website: http://git-scm.com/downloads
  2. Install - Git-[..].exe

Start with GIT

To initiate Git operations, various commands can be executed through the command line by navigating to Start > All Programs > Git > Git CMD/Git Bash.

Some of Git commands

  1. Git --version: This command is used to show Git version.
    Git Command
  2. Git init: This command is used to Initialize a new Git repository or to start a new Git repository.
    Git Test
    As you can see in the above screenshot inside folder one hidden folder will be generated, this .git folder is helping to track the repository activities .
  3. Git clone <repository url>: This command is used to clone repository from git hub to new directory.
    Test project
  4. Git Add <filenames separated by coma>: add specified files changes to the staging area.
    Example: Create a text file, add some notes and that file to staging area.
    Test templete
  5. Git add -All/git add: This command is used to add all files changes to the staging area.
  6. Git status: This command is used to know the status of repository.
    Test Templete
  7. Git status short: This command is used to give short status message of repository.
  8. Git commit -m “commit message”: This command is used to record the changes to repository.
    Test templete.txt
  9. Git log: This command is used to show a log of commits or view commits history.
    Initial Commit
  10. Git branch <branchName>: This command is used to create a new branch.
    Branch production
  11. Git checkout <branchName>: This command is used to switch to the specific branch.
    Production
  12. Git merge <branchNameToBeMerged>: This command is used to merge changes from a different branch to the current branch.
    Git merge main
  13. Git push origin <branchName>: This Command is used to push changes from a local branch to a remote repository.
    Code
  14. Git pull origin <branchName>: This Command is used to Fetch changes from a remote repository and merge them into the current branch.Git Pull origin production
  15. Git remote add <name> <repository URL>: This command is used to Add a new remote repository with a specified name and URL.