Day 9 Task: Deep Dive in Git &
 GitHub for DevOps Engineers.

Day 9 Task: Deep Dive in Git & GitHub for DevOps Engineers.

Β·

4 min read

✱What is Git and why is it important?

Git is a magical time-traveling tool for your code. πŸ•°οΈ

Git is:

  1. History Keeper: It remembers every change you make in your code. πŸ“š

  2. Team Player: Helps many coders work on the same project without messing things up. πŸ‘«πŸ‘¬

  3. Backup Guru: Keeps a copy of your code in case something goes wrong. πŸ’Ύ

  4. Branch Magician: Let you try out new ideas without affecting the main project. 🌳

  5. Collaboration: Makes it easy for coders to share and combine their work. 🀝

Why it's important:

  1. No Chaos: Helps avoid coding chaos and confusion. 🧐

  2. Team Harmony: Makes teamwork smooth and happy. πŸ€—

  3. Safe Coding: Protects your code like a superhero shield. πŸ¦Έβ€β™‚οΈ

  4. Time Travel: Let you go back in time if you make a mistake. ⏰

  5. Global Friend: Coders worldwide use it for a peaceful coding universe. 🌐

Git is like a coding superhero that keeps everything organized, safe, and happy for coders! πŸ¦Έβ€β™‚οΈπŸ’»

✱What is the difference between the Main Branch and the Master Branch?

  1. Master Branch:

    • Old Terminology: In the past, "master" was the default and main branch in Git where stable code lives. 🏑

    • Some projects still use "master" as the main branch.

  2. Main Branch:

    • Modern Term: Many projects now use "main" instead of "master" for the default branch.

    • Reflects a move towards more neutral and inclusive language.

Why the Change?

"Main" is the new cool, while "Master" is a classic term. Main and Master are just different names for the primary branch. However, concerns about potential negative connotations led to a shift towards "main" for inclusivity. Both terms serve the same purpose, storing the primary version of a project's source code. The choice between them depends on cultural shifts and individual preferences within the coding community.

✱Explain the difference between Git and GitHub.

Difference:

  • Git: It's the tool you use on your computer for version control.

  • GitHub: It's the online platform where your code and the superhero Git can mingle with other developers.

✱How do you create a new repository on GitHub?

  1. Go to GitHub:

    • Open your web browser and go to GitHub.
  2. Sign In:

    • If you're not already signed in, click "Sign In" and enter your credentials. πŸšͺπŸ”‘
  3. Create a New Repository βž•:

    • Click on the "+" sign in the top right corner and select "New repository." πŸ†•πŸ“

  4. Fill in Repository Details πŸ“:

    • Give your repository a name. 😊

    • Add a description (Optional).

    • Choose public or private (public means others can see your tree). πŸ”’πŸ‘€

    • Initialize with a README if you want to start your repository with a little welcome note (Optional). πŸ“‹πŸ‘‹

  5. Create Repository:

    • Click the "Create repository" button.

✱What is the difference between local & remote repositories? How to connect local to remote?

  • Local Repository: 🏑 Your personal coding space on your computer, where you create and experiment.

  • Remote Repository: 🌐 The shared space on the internet where your code lives and collaborates with others.

  1. Initialize Git in Your Local Project: 🏑

    • Open your terminal or command prompt.

    • Navigate to your local project folder using the cd command.

    • In your terminal run the below commands,

      1. git init # Initializes a new Git repository locally (if not already initialized).

      2. git add . /git add filename # Stages all the changes for commit.

      3. git commit -m "Initial commit" # Commits the changes.

  2. Connect to Remote Repository: 🌐

    Now, link your local repository to the remote repository on GitHub:

    git remote add origin https://<GITHUB_ACCESS_TOKEN>@github.com/<GITHUB_USERNAME>/<REPOSITORY_NAME>.git

  3. Push Local Changes to Remote Repository: πŸš€

    git push -u origin master

    This command pushes the changes to the "master" branch of the remote repository.

✱Git command to set your user name and email address, which will be associated with your commits

git config --global user.name "your_name"

git config --global user.email ""

git config --list -> Displays all the Git configuration settings currently in use.

Β