Skip to main content

Command Palette

Search for a command to run...

๐Ÿš€ Day 6 - Git & Github #90DaysOfDevOps ๐Ÿš€

Published
โ€ข3 min readโ€ขView as Markdown
๐Ÿš€ Day 6 - Git & Github 
 #90DaysOfDevOps ๐Ÿš€

1. Git Introduction:

Git is a distributed version control system designed to handle everything from small to very large projects with speed and efficiency. It allows multiple developers to collaborate on the same codebase and track changes over time.

2. Setting Up Git:

Install Git:

Configure Git:

  • Set your username:

      git config --global user.name "Your Name"
    
  • Set your email:

      git config --global user.email "youremail@example.com"
    

3. Basic Git Concepts:

  • Repository: A repository, or repo, is like a folder for your project. It contains all the files and the history of changes.

  • Commit: A commit is a snapshot of your repository at a specific point in time.

  • Branch: A branch is a separate line of development. It allows you to work on features or fixes without affecting the main codebase.

  • Merge: Merging combines the changes from different branches into one.

  • Pull Request: A pull request is a request to merge changes from one branch into another.

4. Git Commands:

Creating a Repository:

  • Initialize a new repository:

      git init
    

Basic Workflow:

  • Add files to staging area:

      git add <filename>
    
  • Commit changes:

      git commit -m "Commit message"
    

Branching and Merging:

  • Create a new branch:

      git branch <branchname>
    
  • Switch to a branch:

      git checkout <branchname>
    
  • Merge branches:

      git merge <branchname>
    

Remote Repositories (GitHub):

  • Add a remote repository:

      git remote add origin <repository_url>
    
  • Push changes to a remote repository:

      git push origin <branchname>
    
  • Clone a repository:

      git clone <repository_url>
    

5. GitHub:

GitHub is a platform built on top of Git that provides hosting for software development and version control using Git.

Getting Started with GitHub:

  • Sign up for a GitHub account at https://github.com/

  • Create a new repository by clicking on the "+" sign in the top right corner of your GitHub profile page.

Collaborative Development:

  • Fork a repository: This creates a copy of the original repository in your GitHub account.

  • Create a pull request: This allows you to propose changes to the original repository.

  • Review pull requests: Collaborators can review proposed changes and provide feedback.

  • Merge pull requests: Once changes are approved, they can be merged into the main codebase.

Example:

Let's go through a simple example:

  1. Create a Local Repository:

     mkdir myproject
     cd myproject
     git init
    
  2. Create a File and Add Content:

     echo "Hello, Git!" > README.md
    
  3. Add and Commit Changes:

     git add README.md
     git commit -m "Initial commit"
    
  4. Create a GitHub Repository:

  5. Link Local Repository to GitHub:

     git remote add origin <repository_url>
    
  6. Push Changes to GitHub:

     git push -u origin master
    
  7. Collaborative Workflow (Optional):

    • Add collaborators to your GitHub repository.

    • Collaborators can fork the repository, make changes, and create pull requests.

More from this blog

DevOps Journey

8 posts

Versatile professional with expertise in DevOps, AWS, Azure, MERN stack, networking, data center design, Python, MySQL, Flutter, Linux, and data analysis. With a passion for technology and a knack for