0% found this document useful (0 votes)
8 views37 pages

Git Presentation IITG

Uploaded by

krishna
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)
8 views37 pages

Git Presentation IITG

Uploaded by

krishna
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/ 37

GIT AND GITHUB

Yarish Kumar J
BS( Data Science and Artificial Intelligence ) – Cohort 2 – Trimester 1
@ Indian Institute of Technology Guwahati

Senior Software Engineer @ Lululemon.com / Phone: +91-998-004-4534


https://www.linkedin.com/in/yarish-kumar-j/
AUTHOR
AGENDA
▪ Git – why do we need it ? What problem it solves ?
▪ Git Installation
▪ Git Theory and Practice
▪ GitHub
▪ GitHub Student Benefits
▪ GitHub Pages
▪ GitHub collaboration
VERSION CONTROL SYSTEM
▪ A system to track and manage changes to source code.
▪ Facilitates collaboration among developers.
▪ Enables rollback to previous versions.

Types of VCS:
▪ Local VCS – ex. RCS
▪ Centralized VCS (CVCS) – ex. CVS, SVN,Perforce
▪ Distributed VCS (DVCS) – ex. Git, Mercurial
SVN .VS. GIT
INSTALLATION
▪ https://git-scm.com/downloads

▪ Git Cheat Sheet https://education.github.com/git-cheat-sheet-education.pdf


CLONE A REPO
▪ git clone https://github.com/yarishiitg/CalculatorQt.git
GIT INSTALLATION AND CONFIG
Set the global configurations
▪ $ git config - - global user.name “yarishiitg”
▪ $ git config - - global user.email “[email protected]
View configurations
▪ $ git config --list
▪ $ git config user.name
▪ $ git config user.email
Get Help
▪ $ git <command> -h
▪ $ git help <command>
FILE STATES
▪ U – Untracked files
▪ A,M,D – Staged files
GIT COMMANDS
▪ $ git init
▪ $ touch file1.txt
▪ $ git status
▪ $ git log
▪ $ git add file1.txt
▪ $ git status
▪ $ git commit –m “feature 1 implemented”
▪ $ git status
▪ $ git log
GIT COMMANDS
▪ $ git diff
▪ $ git rm file.txt
▪ $ git mv file1.txt file2.txt
▪ $ git diff
▪ $ git diff --staged
▪ $ git diff f13a513 2923bec
▪ $ git diff main feature-1
▪ $ git pull => ( fetch + merge )
▪ $ git fetch => ( fetch only, no merge)
▪ $ git pull origin main
▪ $ git fetch origin
▪ $ git merge origin/main
GIT COMMANDS
▪ $ git blame file.txt
▪ $ git show <sha#>
UNDO YOUR COMMIT
▪ $ git reset --soft HEAD~1 => undo the commit, move the file to staging area
▪ $ git reset –mixed feature.txt => move the file from staging area to working
directory
▪ $ git reset --hard HEAD~3 => last 3 commits are discarded
▪ $ git reset --hard <commit-hash> => resets to specific commit.
▪ $ git reflog
GIT BRANCH
▪ $ git branch
▪ $ git checkout –b feature2
▪ $ touch file2.txt
▪ $ git add file2.txt
▪ $ git commit –m “feature2 implemented”
GIT MERGE
▪ $ git checkout main
▪ $ git merge feature2
GIT MERGE CONFLICT
▪ $ git merge feature2
▪ $ # fix the merge conflict by opening the file
▪ $ git add file2.txt
▪ $ git commit -m “feature 2 merge conflict resolved”
GIT STASH – SAVE TEMP FILES BEFORE
COMMIT
▪ $ git stash list
▪ $ git stash
▪ $ git stash push –m “my bug fix #123”
▪ $ git stash –u
▪ $ git stash apply stash@{0}
▪ $ git stash show –p stash@{0}
▪ $ git stash - - patch

GIT STASH COMMANDS
▪ git stash - Save all changes to the stash.
▪ git stash push -m 'message' - Save changes with a message.
▪ git stash list - Show all stashes.
▪ git stash apply - Apply the latest stash without removing it.
▪ git stash pop - Apply the latest stash and remove it.
▪ git stash drop stash@{n} - Delete a specific stash.
▪ git stash clear - Remove all stashes.
▪ git stash -u - Stash untracked files along with tracked ones.
▪ git stash show stash@{n} - Show changes in a specific stash.
GIT IGNORE
GIT REBASE
GIT SQUASH
GITHUB
▪ What is GitHub?
GitHub is a cloud-based platform that uses Git for version control, enabling developers
to collaborate and manage projects efficiently.
▪ Features:
• Repository Hosting: Centralized storage for code.
• Collaboration Tools: Pull requests, code reviews, and issue tracking.
• Version Control: Built on Git to track changes and manage history.
• CI/CD Integration: Automate testing and deployment workflows.
• GitHub Pages: Host static websites directly from repositories.

▪ Why Use GitHub?


• Simplifies collaboration on projects.
• Provides robust tools for team management.
• Integrates seamlessly with DevOps pipelines.
PUSH TO REMOTE REPO
GITHUB PERSONAL ACCESS TOKEN
▪ Settings → Developer settings
→ Personal Access Tokens
→ Tokens (classic).
GITHUB PERSONAL ACCESS TOKEN
▪ Settings → Developer settings
→ Personal Access Tokens
→ Tokens (classic).

▪ https://github.com/settings/tokens
PUSH TO REMOTE REPO
▪ echo "# merge-example" >> README.md
▪ git init
▪ git add README.md
▪ git commit -m "first commit"
▪ git branch -M main
▪ git remote add origin https://github.com/yarishiitg/merge-example.git
▪ git push -u origin main
AUDIT OTHER’S REPOSITORY
▪ https://github.com/yarishiitg/CalculatorQt
FORK
▪ https://github.com/yarish/CalculatorQt
GIT PULL REQUEST ( PR )
▪ Definition:
A pull request (PR) is a way to propose changes to a repository, enabling
collaboration and review before merging.
▪ Key Features of Pull Requests:
• Enables code review and feedback.
• Tracks changes, comments, and approvals.
• Facilitates merging feature branches into the main branch.
▪ Why Use Pull Requests?
• Improve code quality through peer reviews.
• Maintain a clean and controlled development workflow.
• Enable collaboration on team projects or open-source contributions.
GIT PULL REQUEST ( PR )
▪ $ git checkout -b feature/my-feature
▪ $ echo "New feature" > feature.txt
$ git add feature.txt
$ git commit -m "Add new feature”
▪ git push origin feature/my-feature
▪ Open a Pull Request on GitHub:
• Navigate to Pull Requests → New Pull Request.
• Select source branch (feature/my-feature) and target branch (main).
• Add a title, description, and reviewers.
GITHUB STUDENT BENEFITS
▪ https://education.github.com/pack
GITHUB PAGES
GITHUB COPILOT – AI PAIR PROGRAMMER
OH-MY-ZSH – CUSTOMIZE YOUR TERMINAL

https://ohmyz.sh/
MARKDOWN SYNTAX
▪ Cheat sheet https://github.com/lifeparticle/Markdown-
Cheatsheet?utm_source=chatgpt.com
NEW INITIATIVE : MINI PROJECT & DEMO
Missed opportunity!
▪ C Programming
▪ Excel Data Analysis with Statistics
THANK YOU!
Yarish Kumar J
BS( Data Science and Artificial Intelligence ) – Cohort 2 – 2024
@ Indian Institute of Technology Guwahati

Senior Software Engineer @ Lululemon.com


Phone: +91-998-004-4534
https://www.linkedin.com/in/yarish-kumar-j/

You might also like