Skip to content
Team Collaboration with Git and GitHub

Summary - Team Collaboration With Git And GitHub

Git

Tool: Distributed version control system.
Usage: Manages code versions locally.
Commands: commit, merge, branch, etc.

GitHub

Platform: Web-based Git repository hosting.
Features: Pull requests, issues, project management.
Usage: Sharing and collaborating online.

Key Differences

Git: Local version control.
GitHub: Online collaboration and hosting.

GitHub UI Overview

Creating a Repository

Go to "Repositories" and click "New".
Fill in details and choose visibility.
Optionally add a README file.
Click "Create repository".

Adding Collaborators

Go to repository "Settings".
Click "Manage access" and "Invite a collaborator".
Enter username/email and send invitation.

Cloning a Repository

Setting Up SSH Key

Generate SSH Key
Open SSH Config
Add SSH Key to GitHub:
Copy the key:
Go to GitHub: Settings > SSH and GPG keys > New SSH key
Paste the key and save.

Cloning a Repository

Copy SSH URL: Go to repository on GitHub, click "Code", and copy the SSH URL.
Clone Repository:
Command: git clone git@github.com:username/repository.git

Remote Repository Operations

Push

Command: git push origin branch-name

Pull

Command: git pull origin branch-name

Fetch

Command: git fetch origin

Remote Tracking Branch

Tracks state of a remote branch (e.g., origin/main).

Hands-on Operations

Pushing Changes

Commit locally: git commit -m "commit message"
Push to remote: git push origin branch-name

Pulling Changes

Fetch and merge: git pull origin branch-name

Fetching Changes

Fetch only: git fetch origin
Optional manual merge: git merge origin/branch-name

Pull Requests (PR) in GitHub

Purpose: Facilitates code review, collaboration, and documentation.
Review: Team reviews, suggests improvements, and runs CI tests.
Merge Options: Squash and merge, rebase and merge, or create a merge commit.

Forking

Purpose: Create a personal copy for independent development.
Steps: Fork repository, clone it locally, make changes, and commit.

Managing Multiple Remotes

Adding a Remote

Command: git remote add remote-name URL

Fetching from Multiple Remotes

Command: git fetch remote-name

Pushing to Multiple Remotes

Command: git push remote-name branch-name

Example Workflow

Add upstream remote: git remote add upstream URL
Fetch upstream changes: git fetch upstream
Merge changes: git merge upstream/main
These concepts of team collaboration with Git and GitHub will help you master Git. For more detailed information, refer to the Notion link: .
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.