# Day 1: Mastering Git and GitHub

---

### **Introduction**

Welcome to the world of version control and collaborative development! Git and GitHub have revolutionized the way we manage code, collaborate with teams, and track changes in software projects. In this comprehensive guide, I will take you on an in-depth journey through the fundamental concepts of Git and GitHub, starting from basic command-line operations to more advanced topics like branching, forking, and pull requests. Whether you're a beginner or looking to deepen your Git knowledge, this guide has you covered.

### **Developer Journey**

> <mark>Learn to Code --- Attend Events --- Participate in Hackathon --- Volunteer --- Freelance --- Apply for developer Job</mark>

> **<mark>Learn to Code --- Post your Own Projects --- Contribute to Open Source --- Internship --- Apply for developer Job</mark>**

### **Section 1: Basic CMD Commands**

Let's begin with the fundamentals of command-line operations on a Windows system. These commands are essential for navigating your file system and managing files and folders effectively.

```bash
notepad file-name       # Creates and opens a file in Notepad
code .                  # Opens VS code                                            
cls                     # Clears the screen
cd                      # Change directory
cd ..                   # Move up one level
mkdir                   # Create a new folder
dir                     # List all files in the folder
dir /a                  # Show hidden files
rmdir /s                # Delete a folder with all contents
rmdir                   # Delete an empty folder
echo > filename.ext     # Create new files in the folder
del "filename"          # Delete files
del /f                  # Force delete files
del *.*                 # Delete all files in the current folder
del "word*"             # Delete files whose names start with "word"
del "*word"             # Delete files that end with your specified word
```

### **Section 2: Git Commands (Local Repositories)**

Now, let's dive into the essential Git commands for managing your local codebase effectively.

```bash
git init                # Initialize a Git repository
git add                 # Move a file to the staging area
git commit -m "message" # Commit changes to the local repository
git status              # Show the current status of updates
git log                 # Display commitment messages
git diff "file"         # Display differences (changes) made to a specific file
git checkout "file"     # Revert any local changes made to that file
```

### **Section 3: Pushing to GitHub**

> <mark>Working Directory ---&gt; Staging Area ---&gt; Local Repository ---&gt; Remote Repository</mark>

Learn how to push your local repository to GitHub, making your code accessible to others.

```bash
git remote add origin https://github.com/Username/RepositoryName.git
git branch -M main
git push -u origin main
```

### **Section 4: Creating a New Repository on GitHub**

Explore how to create a new GitHub repository from the command line. It involves setting up a central location to store, manage, and collaborate on software development or other digital content. Users can define repository details, configure access controls, and initialize the repository with their project files, enabling efficient version control and collaboration with teammates or the open-source community.

```bash
echo "# Test" >> README.mEd
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/Username/RepositoryName.git
git push -u origin main
```

### **Section 5: .gitignore**

Use a `.gitignore` file to specify files and directories to exclude from Git commits, keeping your repository clean and secure.

```bash
# .gitignore content
*.log
secret.txt
# and more...
```

### **Section 6: Cloning a Repository**

Discover how to clone a remote repository to your local machine for development.

```bash
git clone url
```

### **Section 7: Branching and Merging**

Understand the essential concepts of branching and merging in Git.

**What is a Branch?** In Git, a branch is a separate line of development within a repository. It allows you to work on features, bug fixes, or experiments without affecting the main codebase (usually referred to as the "master" or "main" branch).

**What is Merging?** Merging is the process of combining changes from one branch into another. You typically merge a feature branch back into the main branch (e.g., "master" or "main") to incorporate your changes into the main codebase.

```bash
# Creating a new branch
git branch feature-branch

# Switching to a branch
git checkout feature-branch

# Creating and switching to a new branch
git checkout -b feature-branch

# Merging branches
git checkout main
git merge feature-branch

# Deleting a branch
git branch -d feature-branch
```

### **Section 8: Forking and Pull Requests**

**What is a Fork?** Forking is the process of creating a copy of a repository (usually a public one) from one user's account or organization to another user's account or organization. The new copy is entirely separate from the original but starts with the same codebase.

**What are Pull Requests?** In collaborative workflows, such as those used on platforms like GitHub or GitLab, developers often create pull requests or merge requests to propose and discuss changes before merging them into the main branch. This allows for code review and collaboration.

Collaborate effectively on open-source projects using forks and pull requests.

* Fork a Repository
    
* Make Changes and Create a Pull Request
    
* Collaborate and Review
    
* Merge the Pull Request
    

### **Section 9: git pull**

Combine fetching and merging in a single step to keep your local repository up to date.

```bash
git pull
```

### **Section 10: git reset**

Learn how to undo commits and reset your repository when necessary.

```bash
git reset <hashid> #Visible on git log command
```

### **Section 11: Expressing Gratitude**

As I embark on this thrilling journey of learning, I would like to extend my heartfelt gratitude to two individuals and their exceptional courses that have been guiding lights in my quest for knowledge.

**Kunal Kushwaha:**

I have been fortunate to follow the enlightening "Java + DSA + Interview Preparation Course" by Kunal Kushwaha, a comprehensive and free playlist available on YouTube. His dedication to making complex concepts accessible and his commitment to the community are truly admirable. [Complete Git and GitHub Tutorial.](https://youtu.be/apGV9Kg7ics?si=_1jPzmPvaG-MPp8o)

**Dr. Angela Yu:**

Another invaluable resource that has been pivotal in my journey is the, "The Complete 2023 Web Development Bootcamp" by Dr. Angela Yu on Udemy. With this course, I have been diving deep into the world of web development, exploring HTML, CSS, JavaScript, Node.js, React, MongoDB, Web3, and DApps. Dr. Angela Yu's course has provided me with not only the knowledge but also the practical skills necessary to become a full-stack web developer. [**The Complete 2023 Web Development Bootcamp**](https://www.udemy.com/share/1013gG3@y6eNzDYl_NUycNP6JRIBgnY01UHrron5BSN733b2zN1ZkvfMBReTfDByhwKxjev8AA==/)

Thank you once again to Kunal Kushwaha and Dr. Angela Yu for their incredible contributions to the learning community.

### Conclusion

In this guide, we've delved into the essential aspects of Git and GitHub, from mastering basic command-line operations to creating repositories, managing branches, and collaborating effectively. Git and GitHub are powerful tools that can enhance your coding experience and teamwork. As you progress, remember the significance of continuous learning and practice.

As you continue your journey in technology and software development, stay curious, share your knowledge, and keep pushing boundaries. Together, we can make remarkable strides in this ever-evolving field. Thank you for being part of this learning adventure, and I look forward to our continued exploration and innovation.

Until then, happy coding!

---
