| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Welcome to the ultimate guide to mastering Git and GitHub! 👋 This repository is designed to be a beginners guide to learn and get a handy reference for Git & GitHub.
Before you can use Git, you need to set it up on your computer.
After installing Git, introduce yourself! This information will be attached to every commit you make.
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"The best way to learn is by getting hands-on with the concept. In the steps below, you will practice the complete, basic workflow of contributing to an open-source project on GitHub.
What you'll be doing: You'll create your own copy of this project, download it to your computer, make a small change, and then propose that your change be added to the main project.
Note
Don't worry if you don't understand what forking, cloning or pull requests mean yet. Just follow the steps, and you'll understand it all by the end of this tutorial!
Get Started by following these steps:
git clone [the-url-you-copied]git add CONTRIBUTING.md
git commit -m "Add [Your Name] to contributors"
git push origin mainCongratulations! You've just completed the core workflow of a GitHub contributor. 🎉
Important
Run all the commands on your cmd or git bash
A repository is a folder for your project that contains all its files and the entire history of changes.
🚀 Try it yourself! Create a new project on your local machine.
mkdir my-first-repo cd my-first-repo git initThe git init command creates a hidden .git subfolder, which turns the directory into a Git repository.
A commit is a snapshot of your changes. It's a saved state of your code. This is a two-step process:
🚀 Try it yourself! Let's make your first local commit.
# In your 'my-first-repo' directory echo "Hello, Git!" > greeting.txt git status # See that greeting.txt is "untracked" git add greeting.txt git status # Now see it's "staged for commit" git commit -m "Add greeting file" git log # See your commit history!
A branch is an independent line of development. You create branches to work on new features or bug fixes without disturbing the main codebase (often the main branch).
🚀 Try it yourself! Create a branch to test a new idea.
# Create a new branch and switch to it git checkout -b new-idea # Make a change on this new branch echo "This is a new idea." >> greeting.txt # Commit the change on the 'new-idea' branch git add greeting.txt git commit -m "Experiment with a new idea" # Switch back to your main branch git checkout main # Notice that greeting.txt no longer contains "This is a new idea." cat greeting.txt
Merging (git merge) combines the changes from one branch into another. This is how you integrate a new feature into your main codebase after you're done working on it.
🚀 Try it yourself! Merge the new-idea branch you created.
# Make sure you are on the main branch git checkout main # Merge the changes from 'new-idea' into 'main' git merge new-idea # Check the file - the changes are now here! cat greeting.txt
This happens when Git can't automatically merge two branches, usually because they have conflicting changes on the same line of a file. You have to manually edit the file to resolve the conflict before the merge can be completed.
git stash temporarily shelves changes you've made so you can switch branches to work on something else without committing incomplete work.
🚀 Try it yourself!
# On your main branch, make an edit but don't commit echo "An unfinished thought..." >> thoughts.txt git status # Shows an uncommitted change # Stash the change to work on something else git stash git status # Your working directory is now clean! # Bring your changes back git stash pop git status # Your change is back
GitHub Issues are a built-in bug and task tracker for your repository. They're perfect for keeping track of ideas, bugs, and tasks. You can create them on the "Issues" tab on your GitHub repository page.
This is the heart of collaboration on GitHub.
You've now learned the core concepts of Git and GitHub! Keep practicing, and you'll be a pro in no time.
| Apna College Git/GitHub Tutorial freeCodeCamp Git/GitHub Tutorial |
|---|
If you found this guide helpful, consider giving it a star ⭐ and helps other discover it!
| Back | FazBrowse Home | New Git URL |