SlideShare a Scribd company logo
git入门与实践
ghosTM55
Version Control System
VCS is a kind of system designed to record the changes of
files under control in certain directory
A.K.A Revision Control System
Mainly used in development projects
Local Version Control System
Centralized Version Control System
SVN
CVS
Distributed Version Control System
git
bazaar
BitKeeper
Git 入门 与 实践
History of git
In 2005, Linux kernel team can't use BitKeeper free of
charge any more
So Linus and other guys designed a brand new distributed
version control system, called git
Inspired by some good features in BitKeeper, git does dvcs
better, especially in speed, it's f***ing fast
Basic concepts about git
git record the stage status and files via snapshot, not like other VCS record
the diff to the former commit .
Nearly all the operations in git can be done locally, so it's more friendly to
the people who can't use network when they want to work on their projects
And of cuz, it's fast due to there is no latency for local operations
git use 40-bit SHA1-HASH to record everything in its repo
Files in git repo may have 4 kind of status
Untracked
Staged
Committed
Modified
git repo is generally made up by three parts
Working directory(git-repo/)
git directory(git-repo/.git/)
Staging area(a file in git directory)
Install git
debian, ubuntu ...
aptitude install git-core
fedora, centos ...
yum install curl-devel expat-devel gettext-devel openssl-
devel zlib-devel
tar xvf git-xxx.tar.gz && cd git-xxx && make all && make
install
yum install git-core(use epel repo maintained by fedora
project)
gentoo
emerge git-core
Mac OS X
get macports && port install git-core
git configuration
Three configuration files using in git
/etc/gitconfig: system-wide configuration
~/.gitconfig: user configuration
git-repo/.git/config:project configuration
git config --global user.name "ghosTM55"
git config --global user.emal "thomas@shlug.org"
git config --global core.editor emacs
'git help config' for more info
Begin git
Initialize a git repo
mkdir git-repo-name && cd git-repo-name && git init
mkdir git-repo.git && cd git-repo.git && git init --bare
Get a git repo from internet (or from other directories local)
git clone git-repo-url
git clone git-repo-url dir-name
github.com
Start to work
Add files to be tracked by git: git add filename
unstage a file: git reset HEAD filename
Checkout the current git status: git status
Commit your work: git commit filename [-a] [-m]
Modify your work and see what happened
diff utility in git: git diff
rename a file tracked by git: git mv filename_a filename_b
remove a file tracked by git: git rm filename
View commit histories
View commit histories: git log
View the last N commit logs: git log -N
View logs one line per commit log: git log --pretty=oneline
View the branch ASCII graph in log: git log --graph
Customize the output format: git log --pretty=format:"format_arguments"
%H Commit hash
%h Abbreviated commit hash
%T Tree hash
%t Abbreviated tree hash
%P Parent hashes
%p Abbreviated parent hashes
%an Author name
%ae Author e-mail
%ad Author date (format respects the date= option)
%ar Author date, relative
%cn Committer name
%ce Committer email
%cd Committer date
%cr Committer date, relative
%s Subject
branch, branch, branch
Killer feature in git
Branch is actually a pointer point to a certain commit .
git use HEAD pointer to determine which branch you're working in
Create a git branch: git branch branch_name
Switch to a certain branch: git checkout branch_name
Delete a branch: git branch -d branch_name
View details about the current branch: git branch -v
Checkout a remote branch: git branch repo_name/branch_name
Merge the works: git merge branch_name
Take care of the conflicts if they exists when you merge
git rebase
git merge vs. git rebase
http://gitguru.com/2009/02/03/rebase-v-merge-in-git/
Milestones
There are two kinds of tags in git
Annotated tag
Lightweight tag
Create an annotated tag: git tag -a tag_ver -m 'comment'
You can sign GPG key in an annotated tag
Annotated tag is a commit
Create a lightweight tag: git tag tag_ver
View details about a tag: git show tag_ver
Push your tags to the repo server: git push repo_name --
tags
Be a victor
Modify the last commit: git commit --amend
Nu-clear option: filter-branch
git filter-branch --tree-filter 'modify script(in bash)' HEAD
git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "schacon@localhost" ];
then
GIT_AUTHOR_NAME="Scott Chacon";
GIT_AUTHOR_EMAIL="schacon@example.com";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
Time machine in git:
git reset --soft commit-SHA1-value
git reset --hard commit-SHA1-value
git on the air
Default remote is called origin
Default branch is called master
Fetch the work on a certain remote repo:
git fetch remote_name [branch_name]
git pull remote_name [branch_name]
Push your work:
git push remote_name branch_name
People mostly use ssh as the git protocol
git clone ssh://user@host:/path/to/git-repo
Misc
Ignore certain files in git working directory: .gitignore
git command alias: git config --global alias.alias_name
'command_name'
Stashing
Create a stash: git stash
Apply a stash: git stash apply
Create a stash branch: git stash branch branch_name
Apply the patches directly in git: git apply patch_file
Another killer feature: git cherry-pick
git cherry-pick --help
merge specified commit to a branch with cherry-pick and
rebase
Migration from SVN: git svn clone svn-repo-url
git workflows
Centralized workflow
Integration-Manager workflow
1. The project maintainer pushes to their public repository.
2. A contributor clones that repository and makes changes.
3. The contributor pushes to their own public copy.
4. The contributor sends the maintainer an e-mail asking them to pull
changes.
5. The maintainer adds the contributor’s repo as a remote and merges
locally.
6. The maintainer pushes merged changes to the main repository.
Dictator and Lieutenants workflow
1. Regular developers work on their topic branch and rebase their work
on top of master. The master branch is that of the dictator.
2. Lieutenants merge the developers’ topic branches into their master
branch.
3. The dictator merges the lieutenants’ master branches into the
dictator’s master branch.
4. The dictator pushes their master to the reference repository so the
other developers can rebase on it.
More resources about git
Pro Git: progit.org
git community book: book.git-scm.com
github.com
http://www.ghostunix.org/blog
Start using it!
Thank you
Ad

More Related Content

What's hot (19)

Git in 5 Minutes
Git in 5 MinutesGit in 5 Minutes
Git in 5 Minutes
Robert Dumas
 
Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By Swawibe
Md Swawibe Ul Alam
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
DSC GVP
 
Git 101
Git 101Git 101
Git 101
jayrparro
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
Arulmurugan Rajaraman
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
Abdul Basit
 
Git commands
Git commandsGit commands
Git commands
Viyaan Jhiingade
 
Tài liệu sử dụng GitHub
Tài liệu sử dụng GitHubTài liệu sử dụng GitHub
Tài liệu sử dụng GitHub
viet nghiem
 
Git the fast version control system
Git the fast version control systemGit the fast version control system
Git the fast version control system
Jeroen Rosenberg
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
Safique Ahmed Faruque
 
Git basics
Git basicsGit basics
Git basics
Denys Haryachyy
 
Git Developer Cheatsheet
Git Developer CheatsheetGit Developer Cheatsheet
Git Developer Cheatsheet
Abdul Basit
 
Git
GitGit
Git
Gayan Kalanamith Mannapperuma
 
Git and github introduction
Git and github introductionGit and github introduction
Git and github introduction
John(Qiang) Zhang
 
Git
GitGit
Git
Hanokh Aloni
 
Git presentation
Git presentationGit presentation
Git presentation
Vikas Yaligar
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
Nilay Binjola
 
A Quick Start - Version Control with Git
A Quick Start - Version Control with GitA Quick Start - Version Control with Git
A Quick Start - Version Control with Git
Dmitry Sheiko
 
Git tutorial
Git tutorial Git tutorial
Git tutorial
TingYen Lee
 

Viewers also liked (9)

VP07Escape Workshop Tilburg
VP07Escape Workshop TilburgVP07Escape Workshop Tilburg
VP07Escape Workshop Tilburg
maurice.vanderfeesten
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
Terry Wang
 
Get the Facts: Oracle's Unbreakable Enterprise Kernel
Get the Facts: Oracle's Unbreakable Enterprise KernelGet the Facts: Oracle's Unbreakable Enterprise Kernel
Get the Facts: Oracle's Unbreakable Enterprise Kernel
Terry Wang
 
Staff development Thesis Summary
Staff development Thesis SummaryStaff development Thesis Summary
Staff development Thesis Summary
Craig Nansen
 
ALUI 6.5
ALUI 6.5ALUI 6.5
ALUI 6.5
Terry Wang
 
Calvin and Hobbes - Learning is Fun
Calvin and Hobbes - Learning is FunCalvin and Hobbes - Learning is Fun
Calvin and Hobbes - Learning is Fun
Craig Nansen
 
49 Cach Song Khoe
49 Cach Song Khoe49 Cach Song Khoe
49 Cach Song Khoe
Tom Doan
 
Book Report - Foxtrot
 Book Report - Foxtrot Book Report - Foxtrot
Book Report - Foxtrot
Craig Nansen
 
Git
GitGit
Git
Terry Wang
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
Terry Wang
 
Get the Facts: Oracle's Unbreakable Enterprise Kernel
Get the Facts: Oracle's Unbreakable Enterprise KernelGet the Facts: Oracle's Unbreakable Enterprise Kernel
Get the Facts: Oracle's Unbreakable Enterprise Kernel
Terry Wang
 
Staff development Thesis Summary
Staff development Thesis SummaryStaff development Thesis Summary
Staff development Thesis Summary
Craig Nansen
 
Calvin and Hobbes - Learning is Fun
Calvin and Hobbes - Learning is FunCalvin and Hobbes - Learning is Fun
Calvin and Hobbes - Learning is Fun
Craig Nansen
 
49 Cach Song Khoe
49 Cach Song Khoe49 Cach Song Khoe
49 Cach Song Khoe
Tom Doan
 
Book Report - Foxtrot
 Book Report - Foxtrot Book Report - Foxtrot
Book Report - Foxtrot
Craig Nansen
 
Ad

Similar to Git 入门 与 实践 (20)

Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
9 series
 
Git introduction
Git introductionGit introduction
Git introduction
satyendrajaladi
 
Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
PravallikaTammisetty
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
Nguyen Van Hung
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
Sage Sharp
 
sample.pptx
sample.pptxsample.pptx
sample.pptx
UshaSuray
 
tech winter break workshop on git &git hub.pptx
tech winter break workshop on git &git hub.pptxtech winter break workshop on git &git hub.pptx
tech winter break workshop on git &git hub.pptx
ashishraulin
 
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
Chris Johnson
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
Anuchit Chalothorn
 
git2.ppt
git2.pptgit2.ppt
git2.ppt
ssusered2ec2
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
gdsc13
 
git2nvlkndvslnvdslnlknvdlnlvdsnlknsdvlkn.ppt
git2nvlkndvslnvdslnlknvdlnlvdsnlknsdvlkn.pptgit2nvlkndvslnvdslnlknvdlnlvdsnlknsdvlkn.ppt
git2nvlkndvslnvdslnlknvdlnlvdsnlknsdvlkn.ppt
loleto7559
 
Subversion to Git Migration
Subversion to Git MigrationSubversion to Git Migration
Subversion to Git Migration
Manish Chakravarty
 
Git and GitHub Workshop of GDG on Campus UNSTPB
Git and GitHub Workshop of GDG on Campus UNSTPBGit and GitHub Workshop of GDG on Campus UNSTPB
Git and GitHub Workshop of GDG on Campus UNSTPB
AmaraCostachiu
 
Git Workshop : Getting Started
Git Workshop : Getting StartedGit Workshop : Getting Started
Git Workshop : Getting Started
Wildan Maulana
 
Git workflows automat-it
Git workflows automat-itGit workflows automat-it
Git workflows automat-it
Automat-IT
 
Git github
Git githubGit github
Git github
Anurag Deb
 
Git and GitHUB Explanation and simple coding for CLI
Git and GitHUB Explanation and simple coding for CLIGit and GitHUB Explanation and simple coding for CLI
Git and GitHUB Explanation and simple coding for CLI
kumaresan7751
 
git2.ppt
git2.pptgit2.ppt
git2.ppt
MohammadSamiuddin10
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
9 series
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
Sage Sharp
 
tech winter break workshop on git &git hub.pptx
tech winter break workshop on git &git hub.pptxtech winter break workshop on git &git hub.pptx
tech winter break workshop on git &git hub.pptx
ashishraulin
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
Anuchit Chalothorn
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
gdsc13
 
git2nvlkndvslnvdslnlknvdlnlvdsnlknsdvlkn.ppt
git2nvlkndvslnvdslnlknvdlnlvdsnlknsdvlkn.pptgit2nvlkndvslnvdslnlknvdlnlvdsnlknsdvlkn.ppt
git2nvlkndvslnvdslnlknvdlnlvdsnlknsdvlkn.ppt
loleto7559
 
Git and GitHub Workshop of GDG on Campus UNSTPB
Git and GitHub Workshop of GDG on Campus UNSTPBGit and GitHub Workshop of GDG on Campus UNSTPB
Git and GitHub Workshop of GDG on Campus UNSTPB
AmaraCostachiu
 
Git Workshop : Getting Started
Git Workshop : Getting StartedGit Workshop : Getting Started
Git Workshop : Getting Started
Wildan Maulana
 
Git workflows automat-it
Git workflows automat-itGit workflows automat-it
Git workflows automat-it
Automat-IT
 
Git and GitHUB Explanation and simple coding for CLI
Git and GitHUB Explanation and simple coding for CLIGit and GitHUB Explanation and simple coding for CLI
Git and GitHUB Explanation and simple coding for CLI
kumaresan7751
 
Ad

More from Terry Wang (10)

Introduction to containers, k8s, Microservices & Cloud Native
Introduction to containers, k8s, Microservices & Cloud NativeIntroduction to containers, k8s, Microservices & Cloud Native
Introduction to containers, k8s, Microservices & Cloud Native
Terry Wang
 
Debugging and Configuration Best Practices for Oracle Linux
Debugging and Configuration Best Practices for Oracle LinuxDebugging and Configuration Best Practices for Oracle Linux
Debugging and Configuration Best Practices for Oracle Linux
Terry Wang
 
Btrfs by Chris Mason
Btrfs by Chris MasonBtrfs by Chris Mason
Btrfs by Chris Mason
Terry Wang
 
Oracle Linux Nov 2011 Webcast
Oracle Linux Nov 2011 WebcastOracle Linux Nov 2011 Webcast
Oracle Linux Nov 2011 Webcast
Terry Wang
 
RHEL roadmap
RHEL roadmapRHEL roadmap
RHEL roadmap
Terry Wang
 
Oracle Buys Ksplice
Oracle Buys KspliceOracle Buys Ksplice
Oracle Buys Ksplice
Terry Wang
 
Eliminating Silent Data Corruption with Oracle Linux
Eliminating Silent Data Corruption with Oracle Linux Eliminating Silent Data Corruption with Oracle Linux
Eliminating Silent Data Corruption with Oracle Linux
Terry Wang
 
我的 Ubuntu 之旅
我的 Ubuntu 之旅我的 Ubuntu 之旅
我的 Ubuntu 之旅
Terry Wang
 
Git 101 tutorial presentation
Git 101 tutorial presentationGit 101 tutorial presentation
Git 101 tutorial presentation
Terry Wang
 
WCI 10gR3 overview
WCI 10gR3 overviewWCI 10gR3 overview
WCI 10gR3 overview
Terry Wang
 
Introduction to containers, k8s, Microservices & Cloud Native
Introduction to containers, k8s, Microservices & Cloud NativeIntroduction to containers, k8s, Microservices & Cloud Native
Introduction to containers, k8s, Microservices & Cloud Native
Terry Wang
 
Debugging and Configuration Best Practices for Oracle Linux
Debugging and Configuration Best Practices for Oracle LinuxDebugging and Configuration Best Practices for Oracle Linux
Debugging and Configuration Best Practices for Oracle Linux
Terry Wang
 
Btrfs by Chris Mason
Btrfs by Chris MasonBtrfs by Chris Mason
Btrfs by Chris Mason
Terry Wang
 
Oracle Linux Nov 2011 Webcast
Oracle Linux Nov 2011 WebcastOracle Linux Nov 2011 Webcast
Oracle Linux Nov 2011 Webcast
Terry Wang
 
Oracle Buys Ksplice
Oracle Buys KspliceOracle Buys Ksplice
Oracle Buys Ksplice
Terry Wang
 
Eliminating Silent Data Corruption with Oracle Linux
Eliminating Silent Data Corruption with Oracle Linux Eliminating Silent Data Corruption with Oracle Linux
Eliminating Silent Data Corruption with Oracle Linux
Terry Wang
 
我的 Ubuntu 之旅
我的 Ubuntu 之旅我的 Ubuntu 之旅
我的 Ubuntu 之旅
Terry Wang
 
Git 101 tutorial presentation
Git 101 tutorial presentationGit 101 tutorial presentation
Git 101 tutorial presentation
Terry Wang
 
WCI 10gR3 overview
WCI 10gR3 overviewWCI 10gR3 overview
WCI 10gR3 overview
Terry Wang
 

Recently uploaded (20)

How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 

Git 入门 与 实践

  • 2. Version Control System VCS is a kind of system designed to record the changes of files under control in certain directory A.K.A Revision Control System Mainly used in development projects Local Version Control System Centralized Version Control System SVN CVS Distributed Version Control System git bazaar BitKeeper
  • 4. History of git In 2005, Linux kernel team can't use BitKeeper free of charge any more So Linus and other guys designed a brand new distributed version control system, called git Inspired by some good features in BitKeeper, git does dvcs better, especially in speed, it's f***ing fast
  • 5. Basic concepts about git git record the stage status and files via snapshot, not like other VCS record the diff to the former commit . Nearly all the operations in git can be done locally, so it's more friendly to the people who can't use network when they want to work on their projects And of cuz, it's fast due to there is no latency for local operations git use 40-bit SHA1-HASH to record everything in its repo Files in git repo may have 4 kind of status Untracked Staged Committed Modified git repo is generally made up by three parts Working directory(git-repo/) git directory(git-repo/.git/) Staging area(a file in git directory)
  • 6. Install git debian, ubuntu ... aptitude install git-core fedora, centos ... yum install curl-devel expat-devel gettext-devel openssl- devel zlib-devel tar xvf git-xxx.tar.gz && cd git-xxx && make all && make install yum install git-core(use epel repo maintained by fedora project) gentoo emerge git-core Mac OS X get macports && port install git-core
  • 7. git configuration Three configuration files using in git /etc/gitconfig: system-wide configuration ~/.gitconfig: user configuration git-repo/.git/config:project configuration git config --global user.name "ghosTM55" git config --global user.emal "[email protected]" git config --global core.editor emacs 'git help config' for more info
  • 8. Begin git Initialize a git repo mkdir git-repo-name && cd git-repo-name && git init mkdir git-repo.git && cd git-repo.git && git init --bare Get a git repo from internet (or from other directories local) git clone git-repo-url git clone git-repo-url dir-name github.com
  • 9. Start to work Add files to be tracked by git: git add filename unstage a file: git reset HEAD filename Checkout the current git status: git status Commit your work: git commit filename [-a] [-m] Modify your work and see what happened diff utility in git: git diff rename a file tracked by git: git mv filename_a filename_b remove a file tracked by git: git rm filename
  • 10. View commit histories View commit histories: git log View the last N commit logs: git log -N View logs one line per commit log: git log --pretty=oneline View the branch ASCII graph in log: git log --graph Customize the output format: git log --pretty=format:"format_arguments" %H Commit hash %h Abbreviated commit hash %T Tree hash %t Abbreviated tree hash %P Parent hashes %p Abbreviated parent hashes %an Author name %ae Author e-mail %ad Author date (format respects the date= option) %ar Author date, relative %cn Committer name %ce Committer email %cd Committer date %cr Committer date, relative %s Subject
  • 11. branch, branch, branch Killer feature in git Branch is actually a pointer point to a certain commit . git use HEAD pointer to determine which branch you're working in Create a git branch: git branch branch_name Switch to a certain branch: git checkout branch_name Delete a branch: git branch -d branch_name View details about the current branch: git branch -v Checkout a remote branch: git branch repo_name/branch_name Merge the works: git merge branch_name Take care of the conflicts if they exists when you merge git rebase git merge vs. git rebase http://gitguru.com/2009/02/03/rebase-v-merge-in-git/
  • 12. Milestones There are two kinds of tags in git Annotated tag Lightweight tag Create an annotated tag: git tag -a tag_ver -m 'comment' You can sign GPG key in an annotated tag Annotated tag is a commit Create a lightweight tag: git tag tag_ver View details about a tag: git show tag_ver Push your tags to the repo server: git push repo_name -- tags
  • 13. Be a victor Modify the last commit: git commit --amend Nu-clear option: filter-branch git filter-branch --tree-filter 'modify script(in bash)' HEAD git filter-branch --commit-filter ' if [ "$GIT_AUTHOR_EMAIL" = "schacon@localhost" ]; then GIT_AUTHOR_NAME="Scott Chacon"; GIT_AUTHOR_EMAIL="[email protected]"; git commit-tree "$@"; else git commit-tree "$@"; fi' HEAD Time machine in git: git reset --soft commit-SHA1-value git reset --hard commit-SHA1-value
  • 14. git on the air Default remote is called origin Default branch is called master Fetch the work on a certain remote repo: git fetch remote_name [branch_name] git pull remote_name [branch_name] Push your work: git push remote_name branch_name People mostly use ssh as the git protocol git clone ssh://user@host:/path/to/git-repo
  • 15. Misc Ignore certain files in git working directory: .gitignore git command alias: git config --global alias.alias_name 'command_name' Stashing Create a stash: git stash Apply a stash: git stash apply Create a stash branch: git stash branch branch_name Apply the patches directly in git: git apply patch_file Another killer feature: git cherry-pick git cherry-pick --help merge specified commit to a branch with cherry-pick and rebase Migration from SVN: git svn clone svn-repo-url
  • 16. git workflows Centralized workflow Integration-Manager workflow 1. The project maintainer pushes to their public repository. 2. A contributor clones that repository and makes changes. 3. The contributor pushes to their own public copy. 4. The contributor sends the maintainer an e-mail asking them to pull changes. 5. The maintainer adds the contributor’s repo as a remote and merges locally. 6. The maintainer pushes merged changes to the main repository. Dictator and Lieutenants workflow 1. Regular developers work on their topic branch and rebase their work on top of master. The master branch is that of the dictator. 2. Lieutenants merge the developers’ topic branches into their master branch. 3. The dictator merges the lieutenants’ master branches into the dictator’s master branch. 4. The dictator pushes their master to the reference repository so the other developers can rebase on it.
  • 17. More resources about git Pro Git: progit.org git community book: book.git-scm.com github.com http://www.ghostunix.org/blog