๐Ÿš€๐Ÿ“… Day 9 DevOps Challenge - ๐Ÿš€ Mastering Git & GitHub for DevOps Excellence

๐Ÿš€๐Ÿ“… Day 9 DevOps Challenge - ๐Ÿš€ Mastering Git & GitHub for DevOps Excellence

ยท

4 min read

1. What is Git and why is it important?

Git is like a digital time machine for your code ๐Ÿ•ฐ๏ธ. It helps programmers work on projects together, keeping track of changes they make ๐Ÿ“. Git is important because it lets you collaborate without messing up each other's work, and you can always go back to older versions if something goes wrong ๐Ÿ”„.

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

Think of them like different names for the same thing ๐Ÿ”„. "Master" used to be a common name, but now many use "Main" to be more respectful. Both are default branches in Git where your latest code lives ๐ŸŒฑ.

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

Git is the tool that helps manage versions of your code, while GitHub is like a website where you can store and share your code with others ๐Ÿช. Think of Git as the toolbox and GitHub as the workshop where you show your projects.

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

It's like making a new online folder for your code ๐Ÿ“. You go to GitHub, click on "New," give your repository a name and description, decide if it's public or private ๐Ÿ”, and then create it. Now you have a place to store your code online!

5. What is the difference between a local & remote repository? How to connect local to remote?

A local repository is on your own computer ๐Ÿ–ฅ๏ธ, while a remote repository is stored on a server (like GitHub) ๐ŸŒ. Connecting them is like setting up a bridge. First, you copy the remote repository's URL. Then, in your local repository, you run a command to add that URL as a "remote." After that, you can send your code from local to remote using commands like "git push" ๐Ÿ“ค. It's like sharing your local project with others on the web!

Task 1: Set your user name and email address

Open your terminal or command prompt and enter these commands, replacing "Your Name" and "your@email.com" with your actual name and email address:

git config --global user.name "Your Name"
git config --global user.email "your@email.com"

To check the configured user name and email address

git config user.name
git config user.email

Task 2: Create a repository on GitHub

  1. Log in to your GitHub account.

  2. Click the "+" icon in the top right corner and select "New repository."

  3. Name your repository "Devops" and add a description if you'd like.

  4. Choose the repository visibility (public or private).

  5. You can choose to initialize the repository with a README file, but for now, let's skip that.

  6. Click "Create repository."

Task 3: Connect your local repository to GitHub

  1. Open your terminal and navigate to the directory where you want to create your local repository.

  2. Run these commands:

git init  # Initialize a new Git repository
git remote add origin https://github.com/YourUsername/Devops.git

Replace "YourUsername" with your actual GitHub username.

Task 4: Create a new file and add content

  1. In your terminal, navigate to your local repository's directory.

  2. Create the necessary folders and the file:

mkdir -p Devops/Git  # Create the required folders
touch Devops/Git/Day-02.txt  # Create the Day-02.txt file
  1. Open the Day-02.txt file in a text editor and add some content.

Task 5: Push your local commits to GitHub

  1. In your terminal, navigate to your local repository's directory.

  2. Run these commands:

git add .  # Stage all changes for commit
git commit -m "Added Day-02.txt and content"  # Commit your changes
git push -u origin master  # Push your changes to the GitHub repository

If you encounter issues, ensure you've followed each step correctly and that your GitHub credentials are properly configured on your local machine.

After pushing changes to GitHub-repo

In a nutshell, pushing changes to a GitHub repository is like sharing your new toy with friends. ๐ŸŽฎ You're putting your latest work where everyone can see and play with it. Just press a button, and your updates go from your computer to a special place on the internet. It's teamwork made easy, like showing off your cool creations and making sure everyone's on the same page. ๐Ÿค So, push away and let the fun collaboration begin! ๐Ÿš€

Did you find this article valuable?

Support Adarsh Jha by becoming a sponsor. Any amount is appreciated!

ย