GIT

GitHub Workflow

GitHub collaboration

GitHub Workflow

GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere.

Create a GitHub Repository

  1. Go to GitHub.com and sign in
  2. Click the "+" icon in the top right
  3. Select "New repository"
  4. Name your repository
  5. Choose public or private
  6. Click "Create repository"

Connect Local Repository to GitHub

After creating a repository on GitHub, connect your local repository:

# Add remote repository
git remote add origin https://github.com/username/repo-name.git

# Verify remote
git remote -v

Push to GitHub

Push your local commits to GitHub:

# Push to main branch
git push -u origin main

# For subsequent pushes
git push

Pull from GitHub

To get the latest changes from GitHub:

git pull origin main

Fork and Clone

To contribute to someone else's project:

  1. Fork the repository on GitHub
  2. Clone your fork: git clone https://github.com/your-username/repo.git
  3. Make changes and commit
  4. Push to your fork
  5. Create a Pull Request

Pull Requests

Pull requests let you tell others about changes you've pushed to a branch in a repository. Once a pull request is opened, you can discuss and review the changes.

Tip: Always pull before you push to avoid conflicts. Use git pull to get the latest changes first.