0% found this document useful (0 votes)
14 views

Data_Science_Workshop_Git_Github

Uploaded by

Kawa Manmi
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)
14 views

Data_Science_Workshop_Git_Github

Uploaded by

Kawa Manmi
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/ 13

Git and GitHub: Essentials

January 12, 2025


What are Git and GitHub?

Git GitHub
▶ Distributed version control system ▶ Web-based hosting service for Git
▶ Tracks changes in source code repositories
▶ Facilitates collaboration ▶ Adds collaboration features
▶ Project management tools
Why Version Control is Important

▶ Track Changes: Monitor who made what changes and when


▶ Revert to Previous Versions: Easily undo mistakes
▶ Collaborate: Work on the same project simultaneously
▶ Branching: Experiment with new features without affecting the main code
▶ Code Review: Facilitate peer review and quality control
▶ Backup: Distributed nature provides built-in backup
Git and GitHub Video

Click here to play the video


(YouTube: Git and GitHub Essentials)
Popular Version Control Systems

Most Popular Other Notable VCS


▶ Git (and platforms using Git) ▶ Subversion (SVN)
▶ GitHub ▶ Mercurial
▶ GitLab
▶ Bitbucket ▶ AWS CodeCommit

Git is the most widely used, but alternatives exist for various needs
Installing Git

Windows Linux
1. Download from git-scm.com ▶ Ubuntu/Debian:
2. Run installer sudo apt-get install git
3. Follow setup wizard ▶ Fedora:
sudo dnf install git
4. Verify: git --version
▶ Verify: git --version
Basic Git Commands - Part 1

# Initialize a new Git repository


git init

# Add files to staging area - Basic Options


git add < file > # Add a specific file
git add . # Add all files ( use with caution !)
git add *. js # Add all files with . js extension
git add folder / # Add all files in a folder

Warning
Using git add . indiscriminately can lead to unwanted files being tracked.
Consider using .gitignore and more specific commands.
Basic Git Commands - Part 2

# More git add options


git add -p # Interactive staging ( patch mode )
git add -u # Update tracked files only
git add -A # Add all changes ( including deletions )
git add -- dry - run # Show what would be added

# Other essential commands


git commit -m " message "
git status

Tip
Use git add -p for more granular control over what you stage. It allows you to
review and stage changes chunk by chunk.
Branching and Merging

# List , create , or delete branches


git branch

# Switch to a different branch


git checkout < branch >

# Merge changes from one branch into the current branch


git merge < branch >

# Delete a branch
git branch -d < branch >
Remote Repository Commands & GitHub Integration

# Add a remote repository ( e . g . , GitHub )


git remote add origin https :// github . com / username / repo . git

# Clone an existing remote repository


git clone https :// github . com / username / repo . git

# Push local changes to the remote repository


git push -u origin main

# Fetch and merge changes from the remote repository


git pull origin main

# Verify remote connection


git remote -v
Remote Repository Commands & GitHub Integration

Example: Linking local repo to GitHub


1. Create GitHub repository
2. Run these commands in your local repo:
git remote add origin https :// github . com / username / repo . git
git branch -M main
git push -u origin main
Advanced Git Commands

# Temporarily store modified , tracked files


git stash

# View commit history


git log

# Reset current HEAD to the specified state


git reset < commit >

# Reapply commits on top of another base tip


git rebase < branch >
Frame Title

▶ https://swcarpentry.github.io/git-novice/key-points.html

You might also like