[go: up one dir, main page]

0% found this document useful (0 votes)
15 views11 pages

Github Collaboration Guide - HTML

Uploaded by

urbnsapiens
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views11 pages

Github Collaboration Guide - HTML

Uploaded by

urbnsapiens
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

GitHub Team Collaboration Guide

Table of Contents

1. Initial Setup for Team Members


2. Branching Strategy
3. Daily Workflow
4. Essential Rules and Best Practices
5. Creating Pull Requests
6. Git Commands Explained
7. PR Comparison and Merging

Initial Setup for Team Members

Step 1: Add Collaborators

Go to your repo → Settings → Collaborators and teams


Click "Add people" and enter team members' GitHub usernames
Send invitations to all team members

Step 2: Team Members Clone the Repository

git clone https://github.com/yourusername/your-repo-name.git


cd your-repo-name

Branching Strategy

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Step 3: Establish Branch Structure

main branch: Production-ready code only


develop branch: Integration branch for features
Feature branches: Individual features (feature/login-system, feature/user-
dashboard)
Hotfix branches: Critical bug fixes (hotfix/security-patch)

Step 4: Create and Switch to Development Branch

git checkout -b develop


git push -u origin develop

Daily Workflow

Step 5: Before Starting Work

git checkout develop


git pull origin develop
git checkout -b feature/your-feature-name

Step 6: Making Changes

# Make your changes


git add .

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
git commit -m "feat: add user authentication system"
git push -u origin feature/your-feature-name

Step 7: Create Pull Request

Go to GitHub → Pull Requests → New Pull Request


Base: develop , Compare: feature/your-feature-name

Add descriptive title and description


Request reviews from team members

Essential Rules and Best Practices

Commit Message Rules

Use conventional commits: type: description

Types: feat , fix , docs , style , refactor , test , chore

Keep first line under 50 characters


Be descriptive but concise

Code Review Rules

At least 2 approvals required before merging


No direct pushes to main or develop branches
Address all review comments before merging
Test code locally before requesting review

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Branch Protection Rules

Go to Settings → Branches → Add rule for main and develop :

Require pull request reviews before merging


Require status checks to pass
Require branches to be up to date before merging
Include administrators in restrictions

Conflict Resolution

# If conflicts arise during PR


git checkout develop
git pull origin develop
git checkout feature/your-feature-name
git merge develop
# Resolve conflicts manually
git add .
git commit -m "resolve: merge conflicts with develop"
git push origin feature/your-feature-name

Creating Pull Requests

Method 1: Through GitHub Web Interface (Recommended)

Step 1: Push Your Feature Branch

# After making your changes and commits

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
git push -u origin feature/your-feature-name

Step 2: Navigate to GitHub

Go to your repository on GitHub


You'll often see a yellow banner saying "Compare & pull request" for your
recently pushed branch
Click that button, OR manually go to the "Pull requests" tab

Step 3: Create Pull Request

Click "New pull request" if you didn't use the banner


Select branches:

Base branch: develop (where you want to merge INTO)

Compare branch: feature/your-feature-name (what you want to merge)

Step 4: Fill Out PR Details

Title: Add user authentication system

Description:
## What does this PR do?
- Implements login/logout functionality
- Adds password hashing with bcrypt
- Creates user session management

## Changes made:
- Added login.js and auth.js files
- Updated database schema for users table
- Added authentication middleware

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
## Testing:
- [x] All existing tests pass
- [x] Added new tests for auth functions
- [x] Manually tested login flow

## Screenshots:
[Add screenshots if UI changes]

Closes #123

Git Commands Explained

Repository Setup Commands

git clone https://github.com/username/repo-name.git - Downloads a complete


copy of the repository from GitHub to your local machine
cd your-repo-name - Changes directory (folder) to enter the cloned repository

Branch Management Commands

git checkout -b develop - Creates a new branch called "develop" AND switches
to it
git checkout develop - Switches to an existing branch called "develop"

git push -u origin develop - Pushes the "develop" branch to GitHub and sets up
tracking

Making Changes Commands

git pull origin develop - Downloads latest changes from the "develop" branch
on GitHub
git add . - Stages all changed files for commit

git commit -m "message" - Saves your staged changes with a descriptive message

git push -u origin feature/branch-name - Uploads your new branch and commits
to GitHub

Common Flags Explained

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
-b : Create new branch

-u : Set up tracking between local and remote branch

-m : Add message inline

-a : Annotated (for tags)

-d : Delete branch (safe)

-D : Force delete branch

--tags : Include tags when pushing

PR Comparison and Merging

Understanding the PR Comparison

When you create a PR, GitHub shows a diff (difference) between two branches:

Base branch (usually develop or main ) - what you want to merge INTO

Compare branch (your feature/branch-name ) - what you want to merge FROM

Example of what you see:

// login.js
- const password = req.body.password;
+ const password = bcrypt.hash(req.body.password, 10);

// new file: auth.js


+ function validateUser(username, password) {
+ // authentication logic
+ }

Merging Options Explained

Option 1: Create a Merge Commit

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Before:
develop: A---B---C
\
feature: D---E---F

After merge:
develop: A---B---C-------G (merge commit)
\ /
feature: D---E---F

Use when: You want to preserve complete history of feature development

Option 2: Squash and Merge

Before:
develop: A---B---C
feature: D---E---F (3 commits)

After merge:
develop: A---B---C---G (single commit with all changes)

Use when: You want clean history without intermediate commits

Option 3: Rebase and Merge

Before:
develop: A---B---C
feature: D---E---F

After merge:
develop: A---B---C---D'---E'---F' (commits replayed)

Use when: You want linear history without merge commits

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Resolving Merge Conflicts

If GitHub shows conflicts:

# Update your feature branch with latest develop


git checkout feature/user-auth
git fetch origin
git merge origin/develop

# Git will show conflict markers in files:


<<<<<<< HEAD
// Your changes
const user = getUser();
=======
// Changes from develop
const user = fetchUserData();
>>>>>>> develop

# Edit the file to resolve conflicts:


const user = fetchUserData(); // Keep the version you want

# Commit the resolution:


git add .
git commit -m "resolve: merge conflicts with develop"
git push origin feature/user-auth

After Merging - Cleanup

# Switch back to develop


git checkout develop

# Get the latest merged changes


git pull origin develop

# Delete your local feature branch


git branch -d feature/user-auth

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
# Clean up remote tracking branches
git remote prune origin

Best Practices for PR Merging

Before Merging:

Ensure all tests pass


Get required number of approvals
Check that feature works as expected
Verify no sensitive data is committed

Merge Strategy Choice:

Squash merge: For feature branches with many small commits


Merge commit: For important features you want to track
Rebase: For clean linear history (advanced teams)

After Merging:

Delete the feature branch


Update any related documentation
Close related issues
Deploy if using continuous deployment

GitHub Team Collaboration Guide

This guide covers the essential workflows for effective team collaboration on
GitHub projects.

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Generated from comprehensive Q&A discussion on GitHub best practices.

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF

You might also like