GitHub Workflow¶
This guide walks you through a classic GitHub workflow—from cloning a repository to merging your changes. It is designed to help you collaborate efficiently and maintain clean version control.
Clone the Repository¶
Open your terminal and navigate to your desired directory:
Replace <repository_url>
with the actual repository link. This creates a local copy of the project.
Create a New Branch¶
Move into the project directory and create a new branch:
Use a descriptive branch name like feature/login-form
or fix/navbar-bug
.
Make Your Changes¶
Open the project in your code editor, modify files as needed, and save your changes.
Stage and Commit Changes¶
Check changes, stage files, and commit:
git status
git add <file_name> # or use `git add .` to stage everything
git commit -m "Add login form with validation"
Push Your Branch to GitHub¶
Push your branch to the remote repository:
Create a Pull Request (PR)¶
Go to your GitHub repository in a browser. Navigate to the Pull Requests tab and click New Pull Request. Choose your branch as the "compare" and the main branch (e.g., main
) as the "base". Add a descriptive title and summary.
Review and Collaborate¶
Team members can comment, suggest changes, or approve the PR. You can push additional commits to the same branch to address feedback.
Merge the Pull Request¶
Once approved and all checks pass, click Merge Pull Request. Resolve any conflicts if prompted.
Clean Up (Optional)¶
Delete your feature branch to keep the repo tidy:
- GitHub offers a "Delete branch" button after merging.
- Or run locally:
Sync Your Local Main Branch (Optional)¶
Switch to your main branch and pull the latest changes: