8000 GitHub - aguraiffi/git-workshop-demo-2025: This repository supports a hands-on workshop introducing Git fundamentals to graduate students and early-stage developers. The 2-hour session covers version control concepts, local and remote workflows, branching, merging, conflict resolution, and GitHub collaboration.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

This repository supports a hands-on workshop introducing Git fundamentals to graduate students and early-stage developers. The 2-hour session covers version control concepts, local and remote workflows, branching, merging, conflict resolution, and GitHub collaboration.

Notifications You must be signed in to change notification settings

aguraiffi/git-workshop-demo-2025

 
 

Repository files navigation

Git Introduction Workshop

Reach here

QR failed loading!

Other Links

Git Introduction Workshop (Word)


Welcome & Objectives

What is Git and Why Use It?

  • Distributed version control (tracks changes, supports collaboration, maintains history)
  • Created in 2005 by Linus Torvalds, the creator of Linux
  • Compared to SVN and Mercurial:
    • Distributed architecture
    • More flexible workflow
  • Relevance for graduate students:
    • Efficient tracking of research and development
    • Enables collaboration
    • Operates offline
    • Industry-standard tool

Git Basic Definitions

Concept Description
Repository (repo) Project tracked by Git, can be local or remote (e.g., GitHub, GitLab).
Commit Snapshot of project state at a certain point, with descriptive message.
Branch Separate development line; used for features without disturbing main project.
Merge Combines changes from different branches.
Clone Copies a remote repository to your local machine.
Push/Pull Send commits to remote repository / Retrieve updates from remote repository.
Fork Personal copy of another user's repository on GitHub/GitLab.

First-Time Setup

Installation & Setup

git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
  • Create and clone repository from GitHub:
git clone <repo-link>

Starting a Repository

  • Initialize local repository:
git init
  • File states: Untracked, Staged, Committed

Basic Workflow

Adding Changes

git add <file>
git add .

Making a Commit

git commit -m "commit message"
git status
git log --oneline

Using Git Diff

  • View unstaged changes:
git diff
  • Diff between commits:
git diff <commit1> <commit2>
  • Diff staged changes:
git diff --staged

Inspecting the Repository

  • Check repository status:
git status
  • Inspect commit details:
git show <commit>

Branching & Merging

Why Branching Matters

  • Enables isolated feature development
  • Keeps main branch stable

Creating & Switching Branches

  • Create and switch branches:
git branch <branch-name>
git switch <branch-name>
  • Shortcut to create and switch:
git switch -c <branch-name>

Merging Changes

  • Merge feature branch into main:
git switch main
git merge <branch-name>
  • Merge methods:
    • Fast-forward (simple merges)
    • 3-way merge (complex merges)
  • Resolve merge conflicts manually:
    • Identify conflicts (git status, git diff)
    • Edit conflicted files, remove markers, commit resolved changes

Branching Best Practices

  • Short-lived branches for features
  • Clear, descriptive branch names
  • Use graphical tools (git log --graph --oneline --all) for visualization

Working with Remotes

What Are Remotes?

  • Repositories on remote servers (GitHub)
  • Supports collaboration via pull requests and issue tracking

Setting Up SSH Keys

  • Create SSH keys:
ssh-keygen -t ed25519 -C "your_email@example.com"
cat ~/.ssh/id_ed25519.pub
  • Add SSH key to GitHub under account settings

Adding a Remote

git remote add origin <URL>
git remote -v

Syncing Changes

  • Push commits:
git push origin <branch-name>
  • Fetch and merge remote changes:
git pull origin <branch-name>
  • Fetch without merging:
git fetch

Forking vs. Cloning

  • Fork: Personal GitHub copy (common in open-source)
  • Pull requests: Propose merging your forked changes into original repository

Common Pitfalls & How to Fix Them

Merge Conflicts Exercise

  • Clone demo repository:
git clone https://github.com/radmanesh/git-workshop-demo-2025
  • Create branches:
git switch -c groupA-branch  # Group A
git switch -c groupB-branch  # Group B
  • Modify team.txt:

    • Group A: Replace "Bob" with "Charlie"
    • Group B: Replace "Bob" with "Dana"
  • Commit changes:

git add team.txt
git commit -m "Changed Bob to Charlie"   # Group A
git commit -m "Changed Bob to Dana"      # Group B
  • Push changes:
git push origin groupA-branch
git push origin groupB-branch
  • Merge on GitHub: Merge Group A’s PR to main
  • Group B pulls main and faces conflicts:
git switch main
git pull origin main
git switch groupB-branch
git merge main  # Resolve conflicts manually

Detached HEAD State

  • Occurs checking out specific commit directly
  • Recover by switching to a branch:
git switch main  # or
git switch -c new-branch

Reverting vs. Resetting

  • Safely undo a commit:
git revert <commit>
  • Rewrite history (with caution):
git reset --hard <commit>

.gitignore Issues

  • Ignore files properly:
    • .gitignore file
    • Remove already-committed files:
git rm --cached <file>

Copilot Online Queries (Optional)

  • View repository history clearly:
git log --oneline --graph --decorate --all
  • Document pull requests clearly with messages and comments for detailed collaboration.

About

This repository supports a hands-on workshop introducing Git fundamentals to graduate students and early-stage developers. The 2-hour session covers version control concepts, local and remote workflows, branching, merging, conflict resolution, and GitHub collaboration.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0