Welcome to the Complete Git and GitHub Guide! This repository provides a comprehensive overview of Git, a distributed version control system, and GitHub, a platform for hosting and collaborating on Git repositories.
- Introduction
- Getting Started with Git
- Working with GitHub
- Advanced Git Techniques
- Best Practices
- Resources
Git is a powerful version control system that allows you to track changes to your code and collaborate with others. GitHub is a web-based platform that uses Git for version control and provides a suite of tools for collaborative development.
To install Git, follow the instructions for your operating system:
- Windows: Download the Git installer from git-scm.com and follow the installation instructions.
- Mac: Use Homebrew to install Git with
brew install git
. - Linux: Use your distribution's package manager to install Git, e.g.,
sudo apt-get install git
.
Here are some basic Git commands to get you started:
git init
: Initialize a new Git repository.git clone <url>
: Clone a remote repository.git status
: Check the status of your repository.git add <file>
: Add a file to the staging area.git commit -m "message"
: Commit changes with a message.git push
: Push changes to the remote repository.git pull
: Pull changes from the remote repository.
- Go to GitHub and sign in.
- Click the "New" button to create a new repository.
- Enter a repository name and description.
- Choose to make the repository public or private.
- Click "Create repository".
To clone a repository, use the git clone
command followed by the repository URL:
git clone https://github.com/username/repository.git
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push the branch to GitHub.
- Open a pull request on GitHub.
- Request a review and address any feedback.
- Merge the pull request once approved.
- Feature Branching: Use separate branches for each feature or bug fix.
- Git Flow: A popular workflow that uses feature, release, and hotfix branches.
- Trunk-Based Development: Keep branches short-lived and merge changes frequently to the main branch.
- Rebasing: Reapply commits on top of another base tip.
- Merging: Combine multiple sequences of commits into one unified history.
Use git stash
to temporarily save changes that are not ready to be committed:
git stash
git stash apply
- Use the imperative mood ("Fix bug" not "Fixed bug").
- Keep the message short and descriptive.
- Provide context if necessary.
- Rebase and squash commits to keep history clean.
- Use meaningful commit messages.
Feel free to contribute to this repository by opening issues and submitting pull requests!
Special thanks to Hitesh Choudhary and his YouTube channel Chai aur Code. For more resources, visit the Chai aur Code documentation.
This project is licensed under the MIT License - see the LICENSE file for details.