https://github.com/radmanesh/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.
https://github.com/radmanesh/git-workshop-demo-2025
git github
Last synced: about 10 hours ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/radmanesh/git-workshop-demo-2025
- Owner: radmanesh
- Created: 2025-04-18T23:14:32.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-22T05:14:12.000Z (about 1 year ago)
- Last Synced: 2025-06-08T09:47:27.495Z (11 months ago)
- Topics: git, github
- Homepage:
- Size: 369 KB
- Stars: 7
- Watchers: 1
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Git Introduction Workshop
## Reach here

## Other Links
### [2-Page Git Cheat-Sheet (PDF)](https://raw.githubusercontent.com/radmanesh/git-workshop-demo-2025/refs/heads/main/CheatSheet.pdf)
### [Wiki (NEW!)](https://github.com/radmanesh/git-workshop-demo-2025/wiki)
### [Git Introduction Workshop (Word)](https://sooners-my.sharepoint.com/:w:/r/personal/radmanesh_ou_edu/Documents/Git%20Introduction%20Workshop.docx?d=wdc22cdcb84e748809bd5b0f1e101d0c8&csf=1&web=1&e=pX0kRV)
---
## 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
- [Create GitHub account](https://github.com/)
- Install Git ([Windows/Mac/Linux](https://git-scm.com/downloads))
- Configure Git globally:
```bash
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
```
- Create and clone repository from GitHub:
```bash
git clone
```
### Starting a Repository
- Initialize local repository:
```bash
git init
```
- File states: **Untracked**, **Staged**, **Committed**
---
## Basic Workflow
### Adding Changes
```bash
git add
git add .
```
### Making a Commit
```bash
git commit -m "commit message"
git status
git log --oneline
```
### Using Git Diff
- View unstaged changes:
```bash
git diff
```
- Diff between commits:
```bash
git diff
```
- Diff staged changes:
```bash
git diff --staged
```
### Inspecting the Repository
- Check repository status:
```bash
git status
```
- Inspect commit details:
```bash
git show
```
---
## Branching & Merging
### Why Branching Matters
- Enables isolated feature development
- Keeps main branch stable
### Creating & Switching Branches
- Create and switch branches:
```bash
git branch
git switch
```
- Shortcut to create and switch:
```bash
git switch -c
```
### Merging Changes
- Merge feature branch into main:
```bash
git switch main
git merge
```
- 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:
```bash
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
```bash
git remote add origin
git remote -v
```
### Syncing Changes
- Push commits:
```bash
git push origin
```
- Fetch and merge remote changes:
```bash
git pull origin
```
- Fetch without merging:
```bash
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:
```bash
git clone https://github.com/radmanesh/git-workshop-demo-2025
```
- Create branches:
```bash
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:
```bash
git add team.txt
git commit -m "Changed Bob to Charlie" # Group A
git commit -m "Changed Bob to Dana" # Group B
```
- Push changes:
```bash
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:
```bash
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:
```bash
git switch main # or
git switch -c new-branch
```
### Reverting vs. Resetting
- Safely undo a commit:
```bash
git revert
```
- Rewrite history (with caution):
```bash
git reset --hard
```
### `.gitignore` Issues
- Ignore files properly:
- `.gitignore` file
- Remove already-committed files:
```bash
git rm --cached
```
---
## Copilot Online Queries (Optional)
- View repository history clearly:
```bash
git log --oneline --graph --decorate --all
```
- Document pull requests clearly with messages and comments for detailed collaboration.