-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Gitchallenge Tws9 #483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Gitchallenge Tws9 #483
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Himanshu |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,149 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
Week 4: Git and GitHub Challenge | ||||||||||||||||||||||||||||||||||||||||||||||||
Welcome to the Week 4 Challenge! In this task you will practice the essential Git and GitHub commands and concepts taught by Shubham Bhaiya. This includes: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Git Basics: git init, git add, git commit | ||||||||||||||||||||||||||||||||||||||||||||||||
Repository Management: git clone, forking a repository, and understanding how a GitHub repo is made | ||||||||||||||||||||||||||||||||||||||||||||||||
Branching: Creating branches (git branch), switching between branches (git switch / git checkout), and viewing commit history (git log) | ||||||||||||||||||||||||||||||||||||||||||||||||
Authentication: Pushing and pulling using a Personal Access Token (PAT) | ||||||||||||||||||||||||||||||||||||||||||||||||
Critical Thinking: Explaining why branching strategies are important in collaborative development | ||||||||||||||||||||||||||||||||||||||||||||||||
To make this challenge more difficult, additional steps have been added. You will also be required to explore SSH authentication as a bonus task. Complete all the tasks and document every step in solution.md. Finally, share your experience on LinkedIn (details provided at the end). | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Challenge Tasks | ||||||||||||||||||||||||||||||||||||||||||||||||
Task 1: Fork and Clone the Repository | ||||||||||||||||||||||||||||||||||||||||||||||||
Fork the Repository: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Visit this repository and fork it to your own GitHub account. If not done yet. | ||||||||||||||||||||||||||||||||||||||||||||||||
Clone Your Fork Locally: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Clone the forked repository using HTTPS: | ||||||||||||||||||||||||||||||||||||||||||||||||
git clone <your-fork-url> | ||||||||||||||||||||||||||||||||||||||||||||||||
Change directory into the cloned repository: | ||||||||||||||||||||||||||||||||||||||||||||||||
cd 2025/git/01_Git_and_Github_Basics | ||||||||||||||||||||||||||||||||||||||||||||||||
Task 2: Initialize a Local Repository and Create a File | ||||||||||||||||||||||||||||||||||||||||||||||||
Set Up Your Challenge Directory: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Inside the cloned repository, create a new directory for this challenge: | ||||||||||||||||||||||||||||||||||||||||||||||||
mkdir week-4-challenge | ||||||||||||||||||||||||||||||||||||||||||||||||
cd week-4-challenge | ||||||||||||||||||||||||||||||||||||||||||||||||
Initialize a Git Repository: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Initialize the directory as a new Git repository: | ||||||||||||||||||||||||||||||||||||||||||||||||
git init | ||||||||||||||||||||||||||||||||||||||||||||||||
Create a File: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Create a file named info.txt and add some initial content (for example, your name and a brief introduction). | ||||||||||||||||||||||||||||||||||||||||||||||||
Stage and Commit Your File: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Stage the file: | ||||||||||||||||||||||||||||||||||||||||||||||||
git add info.txt | ||||||||||||||||||||||||||||||||||||||||||||||||
Commit the file with a descriptive message: | ||||||||||||||||||||||||||||||||||||||||||||||||
git commit -m "Initial commit: Add info.txt with introductory content" | ||||||||||||||||||||||||||||||||||||||||||||||||
Task 3: Configure Remote URL with PAT and Push/Pull | ||||||||||||||||||||||||||||||||||||||||||||||||
Configure Remote URL with Your PAT: | ||||||||||||||||||||||||||||||||||||||||||||||||
To avoid entering your Personal Access Token (PAT) every time you push or pull, update your remote URL to include your credentials. | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
⚠️ Note: Embedding your PAT in the URL is only for this exercise. It is not recommended for production use. | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Replace <your-username>, <your-PAT>, and <repository-name> with your actual GitHub username, your PAT, and the repository name respectively: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
git remote add origin https://<your-username>:<your-PAT>@github.com/<your-username>/90DaysOfDevOps.git | ||||||||||||||||||||||||||||||||||||||||||||||||
If a remote named origin already exists, update it with: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
git remote set-url origin https://<your-username>:<your-PAT>@github.com/<your-username>/90DaysOfDevOps.git | ||||||||||||||||||||||||||||||||||||||||||||||||
Push Your Commit to Remote: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Push your current branch (typically main) and set the upstream: | ||||||||||||||||||||||||||||||||||||||||||||||||
git push -u origin main | ||||||||||||||||||||||||||||||||||||||||||||||||
(Optional) Pull Remote Changes: | ||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+49
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace token-in-URL guidance with safer approaches; prevent PAT leakage. Embedding PATs in remotes is risky (shell history, logs, screenshots, and .git/config). Prefer HTTPS with credential helpers or gh CLI. Apply this diff: -git remote add origin https://<your-username>:<your-PAT>@github.com/<your-username>/90DaysOfDevOps.git
-If a remote named origin already exists, update it with:
-
-git remote set-url origin https://<your-username>:<your-PAT>@github.com/<your-username>/90DaysOfDevOps.git
+git remote add origin https://github.com/<your-username>/90DaysOfDevOps.git
+If a remote named origin already exists, update it with:
+
+git remote set-url origin https://github.com/<your-username>/90DaysOfDevOps.git
+
+Tips:
+- When prompted for credentials on push, use your PAT as the password.
+- Prefer using Git Credential Manager or GitHub CLI (`gh auth login`) to avoid storing secrets in plain text.
+- If you previously embedded a PAT in a URL, rotate the token on GitHub and remove it from `.git/config`. 📝 Committable suggestion
Suggested change
🧰 Tools🪛 LanguageTool[grammar] ~49-~49: There might be a mistake here. (QB_NEW_EN) [grammar] ~52-~52: There might be a mistake here. (QB_NEW_EN) [grammar] ~55-~55: There might be a mistake here. (QB_NEW_EN) [grammar] ~56-~56: There might be a mistake here. (QB_NEW_EN) 🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Verify your configuration by pulling changes: | ||||||||||||||||||||||||||||||||||||||||||||||||
git pull origin main | ||||||||||||||||||||||||||||||||||||||||||||||||
Task 4: Explore Your Commit History | ||||||||||||||||||||||||||||||||||||||||||||||||
View the Git Log: | ||||||||||||||||||||||||||||||||||||||||||||||||
Check your commit history using: | ||||||||||||||||||||||||||||||||||||||||||||||||
git log | ||||||||||||||||||||||||||||||||||||||||||||||||
Take note of the commit hash and details as you will reference these in your documentation. | ||||||||||||||||||||||||||||||||||||||||||||||||
Task 5: Advanced Branching and Switching | ||||||||||||||||||||||||||||||||||||||||||||||||
Create a New Branch: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Create a branch called feature-update: | ||||||||||||||||||||||||||||||||||||||||||||||||
git branch feature-update | ||||||||||||||||||||||||||||||||||||||||||||||||
Switch to the New Branch: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Switch using git switch: | ||||||||||||||||||||||||||||||||||||||||||||||||
git switch feature-update | ||||||||||||||||||||||||||||||||||||||||||||||||
Alternatively, you can use: | ||||||||||||||||||||||||||||||||||||||||||||||||
git checkout feature-update | ||||||||||||||||||||||||||||||||||||||||||||||||
Modify the File and Commit Changes: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Edit info.txt (for example, add more details or improvements). | ||||||||||||||||||||||||||||||||||||||||||||||||
Stage and commit your changes: | ||||||||||||||||||||||||||||||||||||||||||||||||
git add info.txt | ||||||||||||||||||||||||||||||||||||||||||||||||
git commit -m "Feature update: Enhance info.txt with additional details" | ||||||||||||||||||||||||||||||||||||||||||||||||
git push origin feature-update | ||||||||||||||||||||||||||||||||||||||||||||||||
Merge this branch to main via a Pull Request on GitHub. | ||||||||||||||||||||||||||||||||||||||||||||||||
(Advanced) Optional Extra Challenge: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
If you feel confident, create another branch (e.g., experimental) from your main branch, make a conflicting change to info.txt, then switch back to feature-update and merge experimental to simulate a merge conflict. Resolve the conflict manually, then commit the resolution. | ||||||||||||||||||||||||||||||||||||||||||||||||
Note: This extra step is optional and intended for those looking for an additional challenge. | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Task 6: Explain Branching Strategies | ||||||||||||||||||||||||||||||||||||||||||||||||
Document Your Process: | ||||||||||||||||||||||||||||||||||||||||||||||||
Create (or update) a file named solution.md in your repository. | ||||||||||||||||||||||||||||||||||||||||||||||||
List all the Git commands you used in Tasks 1–4. | ||||||||||||||||||||||||||||||||||||||||||||||||
Explain: Write a brief explanation on why branching strategies are important in collaborative development. Consider addressing: | ||||||||||||||||||||||||||||||||||||||||||||||||
Isolating features and bug fixes | ||||||||||||||||||||||||||||||||||||||||||||||||
Facilitating parallel development | ||||||||||||||||||||||||||||||||||||||||||||||||
Reducing merge conflicts | ||||||||||||||||||||||||||||||||||||||||||||||||
Enabling effective code reviews | ||||||||||||||||||||||||||||||||||||||||||||||||
Bonus Task: Explore SSH Authentication | ||||||||||||||||||||||||||||||||||||||||||||||||
Generate an SSH Key (if not already set up): | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Create an SSH key pair: | ||||||||||||||||||||||||||||||||||||||||||||||||
ssh-keygen | ||||||||||||||||||||||||||||||||||||||||||||||||
Follow the prompts and then locate your public key (typically found at ~/.ssh/id_ed25519.pub). | ||||||||||||||||||||||||||||||||||||||||||||||||
Add Your SSH Public Key to GitHub: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Copy the contents of your public key and add it to your GitHub account under SSH and GPG keys. | ||||||||||||||||||||||||||||||||||||||||||||||||
(See Connecting to GitHub with SSH for help.) | ||||||||||||||||||||||||||||||||||||||||||||||||
Switch Your Remote URL to SSH: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Change the remote URL from HTTPS to SSH: | ||||||||||||||||||||||||||||||||||||||||||||||||
git remote set-url origin [email protected]:<your-username>/90DaysOfDevOps.git | ||||||||||||||||||||||||||||||||||||||||||||||||
Push Your Branch Using SSH: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Test the SSH connection by pushing your branch: | ||||||||||||||||||||||||||||||||||||||||||||||||
git push origin feature-update | ||||||||||||||||||||||||||||||||||||||||||||||||
📢 How to Submit | ||||||||||||||||||||||||||||||||||||||||||||||||
Push Your Final Work: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Ensure your branch (e.g., feature-update) with the updated solution.md file is pushed to your fork. | ||||||||||||||||||||||||||||||||||||||||||||||||
Create a Pull Request (PR): | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Open a PR from your branch to the main repository. | ||||||||||||||||||||||||||||||||||||||||||||||||
Use a clear title such as: | ||||||||||||||||||||||||||||||||||||||||||||||||
Week 4 Challenge - DevOps Batch 9: Git & GitHub Advanced Challenge | ||||||||||||||||||||||||||||||||||||||||||||||||
In the PR description, summarize your process and list the Git commands you used. | ||||||||||||||||||||||||||||||||||||||||||||||||
Share Your Experience on LinkedIn: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Write a LinkedIn post summarizing your Week 4 experience. | ||||||||||||||||||||||||||||||||||||||||||||||||
Include screenshots or logs of your tasks. | ||||||||||||||||||||||||||||||||||||||||||||||||
Use hashtags: #90DaysOfDevOps #GitGithub #DevOps | ||||||||||||||||||||||||||||||||||||||||||||||||
Optionally, share any blog posts, GitHub repos, or articles you create about this challenge. | ||||||||||||||||||||||||||||||||||||||||||||||||
Additional Resources | ||||||||||||||||||||||||||||||||||||||||||||||||
Git Documentation: | ||||||||||||||||||||||||||||||||||||||||||||||||
https://git-scm.com/docs | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Creating a Personal Access Token: | ||||||||||||||||||||||||||||||||||||||||||||||||
GitHub PAT Setup | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Forking and Cloning Repositories: | ||||||||||||||||||||||||||||||||||||||||||||||||
Fork a Repository | Cloning a Repository | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
SSH Authentication with GitHub: | ||||||||||||||||||||||||||||||||||||||||||||||||
Connecting to GitHub with SSH | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Understanding Branching Strategies: | ||||||||||||||||||||||||||||||||||||||||||||||||
Git Branching Strategies | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Remove non-technical/personal line to keep docs neutral and professional.
“Jay shree mahakal” is out of scope for technical documentation and may not be appropriate for a community repo.
Apply this diff:
-Jay shree mahakal
📝 Committable suggestion
🧰 Tools
🪛 LanguageTool
[grammar] ~14-~14: There might be a mistake here.
Context: ...ls provided at the end). --- Jay shree mahakal ## Challenge Tasks ### Task 1: Fork and Cl...
(QB_NEW_EN)
🤖 Prompt for AI Agents