This repo is created for learning GitHub.
- Name -> Pravin
- Batch -> CAP08
What is GitHub?
- A web-based platform for version control and collaboration.
- Built on Git, a distributed version control system.
Why Use GitHub?
- Collaborate on projects with others.
- Track changes to your codebase.
- Contribute to open-source projects.
- Showcase your work and build a portfolio.
Basic Concepts and Terminology
- Repository (Repo): A project containing all the files and their history.
- Commit: A snapshot of your changes.
- Branch: A parallel version of your repository.
- Fork: A personal copy of another user's repository.
- Pull Request: A proposal to merge changes from one branch to another.
- Issue: A way to track tasks, enhancements, and bugs.
Creating a GitHub Account
- Visit GitHub and sign up for a free account.
Installing Git
-
Download and install Git from Git-scm.
-
Configure Git with your GitHub credentials:
git config --global user.name "Your Name" git config --global user.email "your-email@example.com"
Git Workflow
- Initialize a repository
- Stage changes
- Commit changes
- Push to a remote repository
Common Git Commands
git init
: Initialize a new Git repositorygit clone <repository-url>
: Clone a repositorygit add <file>
: Stage changesgit commit -m "commit message"
: Commit changesgit push
: Push changes to a remote repositorygit pull
: Fetch and merge changes from a remote repository
Creating a New Repository
- Click on the "New" button on GitHub.
- Fill in the repository details and create.
Cloning a Repository
-
Use the
git clone
command with the repository URL:git clone <https://github.com/username/repository.git>
Committing Changes and Pushing to GitHub
-
Make changes to your files.
-
Stage and commit changes:
git add . git commit -m "Initial commit" git push origin main
Pull Requests and Code Review
- Create a new branch for your changes.
- Push the branch to GitHub.
- Open a pull request on GitHub for code review.
Forking Repositories
- Click the "Fork" button on the repository page to create a personal copy.
Using Branches
-
Create a new branch:
git checkout -b new-branch
-
Switch between branches:
git checkout main
Merging Branches
-
Merge changes from one branch to another:
git checkout main git merge new-branch
Creating and Managing Issues
- Navigate to the "Issues" tab in your repository.
- Click "New issue" to create an issue.
Using GitHub Projects for Task Management
- Create a new project from the "Projects" tab.
- Add issues and pull requests to the project board.
Introduction to GitHub Pages
- A service to host static websites directly from a GitHub repository.
Hosting a Website on GitHub Pages
- Create a new repository or use an existing one.
- Create an
index.html
file in the repository. - Enable GitHub Pages from the repository settings.
Writing Good Commit Messages
- Keep messages clear and concise.
- Use imperative mood (e.g., "Add feature" instead of "Added feature").
Using .gitignore
- Create a
.gitignore
file to exclude files and directories from being tracked. - Common entries include
node_modules/
,.env
, and.log
.
Keeping Your Repository Clean and Organized
- Regularly merge branches.
- Delete obsolete branches.
- Use descriptive names for branches and commits.