Welcome to the Git_and_Github repository! This repository is a comprehensive guide that covers essential Git commands, best practices, and how to effectively use GitHub for collaboration and version control.
- Introduction
- Why Use Git and GitHub?
- Getting Started with Git
- Basic Git Commands
- Working with GitHub
- Branching and Merging
- Advanced Git Features
- Contributing
- License
Git is a powerful distributed version control system that helps developers track changes in their code, collaborate effectively, and maintain a history of modifications. GitHub enhances Git by providing a cloud-based hosting service, enabling teamwork, issue tracking, and code sharing.
✅ Version Control: Keep track of every change in your project. ✅ Collaboration: Work seamlessly with teams across the globe. ✅ Backup & Security: Securely store your code in remote repositories. ✅ Efficient Workflow: Branching, merging, and pull requests make development structured and organized.
dpkg -l | grep git # Check if Git is already installed
sudo apt update
sudo apt install git -y
Download and install Git from git-scm.com.
git --version
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
git init
git clone <repository_url>
- Check Git Status:
git status
- Add Files to Staging Area:
git add <file_name>
orgit add .
- Commit Changes:
git commit -m "Commit message"
- View Commit History:
git log --oneline --graph
- Push Changes to Remote Repository:
git push origin main
- Pull Changes from Remote Repository:
git pull origin main
- Create a GitHub Repository: Sign in to GitHub and create a new repository.
- Connect Local Repository to GitHub:
git remote add origin <repository_url> git branch -M main git push -u origin main
- Fork and Clone Repositories: Contribute to open-source projects by forking repositories and cloning them locally.
- Create Pull Requests: Propose changes to a repository by creating pull requests.
- Manage Issues: Use GitHub Issues to track bugs and improvements.
- Create a New Branch:
git branch <branch_name>
- Switch to a Branch:
git checkout <branch_name>
orgit switch <branch_name>
- Merge Branches:
git checkout main git merge <branch_name>
- Delete a Branch:
git branch -d <branch_name>
- Stash Changes Temporarily:
git stash
- View Stash List:
git stash list
- Apply Stashed Changes:
git stash apply
- Revert a Commit:
git revert <commit_hash>
- Reset to a Previous Commit:
git reset --hard <commit_hash>
- Rebase Branches:
git rebase <branch_name>
Contributions are welcome! If you want to improve this repository, follow these steps:
- Fork the repository on GitHub.
- Create a new branch for your feature or fix.
- Make your changes and commit them.
- Push your changes to your forked repository.
- Create a pull request to merge your changes.
This project is licensed under the MIT License - see the LICENSE file for details.
🚀 Happy Coding with Git & GitHub! 🎉