Command Palette

Search for a command to run...

CELEC Logo

Más que un club

Git & GitHub: Complete Documentation

This guide explains what Git and GitHub are, how they relate, and how to work with them using the most common commands. It includes workflows for both individual and team-based development.


1. Understanding Git & GitHub

What is Git?

Git is a version control system (VCS) that allows developers to:

Git works locally on your machine.

What is GitHub?

GitHub is a remote hosting platform for Git repositories. It enables:

How They Work Together

You:

  1. Write code locally using Git
  2. Push changes to GitHub
  3. Collaborate via pull requests and remote branches

Git = tool on your computer GitHub = website that stores and shares your Git repository


2. Installing Git

Check if Git is installed:

git --version

If not installed, download from: https://git-scm.com/


3. Essential Git Concepts

Repository (repo)

A folder tracked by Git.

Commit

A saved version of your code.

Branch

A separate environment to develop features without breaking the main code.

Remote

A GitHub-hosted version of your repo.

Merge / Pull Request

Combining changes from different branches.


4. Basic Git Commands

Commonly used commands:

git init           # Initialize a new repository
git clone url      # Download a repo

git status         # Check file status
git add .          # Stage changes
git commit -m "msg" # Save changes
git push           # Upload to GitHub
git pull           # Get latest changes

git branch         # List branches
git branch name    # Create branch
git checkout name  # Switch branch
git merge name     # Merge branch into current

git log            # View commit history
git diff           # Compare changes

5. Workflow for Individual Work

Step-by-Step

git clone url

git add .          # or: git add file_name
git commit -m "your message"
git push

Typical Workflow

  1. Edit files
  2. Stage changes → git add
  3. Commit them → git commit
  4. Push to GitHub → git push

6. Team Workflow: Branching & Pull Requests

Below is the standard professional workflow.


Step 1: Create & Work on a Feature Branch

git clone url

# Create a new branch
git branch branch_name

# Set branch to track GitHub remote
git push -u origin branch_name

# Switch to the branch
git checkout branch_name

# Work + stage changes
git add . # or: git add file_name

git commit -m "your message"

git push

Step 2: Create a Pull Request (PR)

On GitHub:

  1. Open the repository
  2. Click Pull Requests → New Pull Request
  3. Select your branch as the source
  4. Add:
    • Title
    • Description
    • Reviewers
  5. Submit PR
  6. Team reviews & approves
  7. Merge into main

Step 3: Clean Up Branch & Update Local Main

# Move back to the main branch
git checkout main   # or master / dev

# Delete the old local branch
git branch -D branch_name

# Confirm remaining branches
git branch

# Get the latest main code
git pull origin main

7. Common Collaboration Commands

Get updates from GitHub

git pull origin main

Fetch all branches

git fetch --all

Merge another branch into your working branch

git merge branch_name

Resolve merge conflicts

Git will mark conflicts in files with:

<<<<<<< HEAD
local changes
=======
remote changes
>>>>>>> branch_name

You must edit manually, then:

git add .
git commit

8. Git Best Practices


9. Git Commit Message Guidelines

Good commit messages:

feat: add login page
fix: resolve database connection issue
refactor: cleanup user auth function
docs: update README

10. Summary

Git helps you manage code locally. GitHub helps teams collaborate remotely. Most workflows revolve around:

Use the commands in this doc as a complete reference for everyday Git & GitHub work.