Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Git and Github
Search
高見龍
May 08, 2013
Technology
5
610
Git and Github
高見龍
May 08, 2013
Tweet
Share
More Decks by 高見龍
See All by 高見龍
為你自己學 Python
eddie
0
550
Generative AI 年會小聚 - AI 教我寫程式
eddie
0
59
讓數據說話:用 Python、Prometheus 和 Grafana 講故事
eddie
0
520
AI 時代的程式語言學習法
eddie
0
99
前端模組解放運動 - importmap
eddie
0
1.3k
Git 和 DevOps - 在混亂的流星群開發流程中找到小確幸
eddie
1
1.1k
模組化前端開發:從亂七八糟到組織有序
eddie
0
1.5k
被 Vue 框架耽誤的建置工具
eddie
2
980
開開心心寫測試,你的程式碼也會微笑
eddie
1
1.2k
Other Decks in Technology
See All in Technology
リーダブルテストコード 〜メンテナンスしやすい テストコードを作成する方法を考える〜 #DevSumi #DevSumiB / Readable test code
nihonbuson
11
5.8k
室長と気ままに学ぶマイクロソフトのビジネスアプリケーションとビジネスプロセス
ryoheig0405
0
320
30分でわかる『アジャイルデータモデリング』
hanon52_
9
2.2k
株式会社EventHub・エンジニア採用資料
eventhub
0
4.2k
飲食店予約台帳を支えるインタラクティブ UI 設計と実装
siropaca
6
1.4k
テストアーキテクチャ設計で実現する高品質で高スピードな開発の実践 / Test Architecture Design in Practice
ropqa
3
710
Culture Deck
optfit
0
330
High Performance PHP
cmuench
0
140
インフラをつくるとはどういうことなのか、 あるいはPlatform Engineeringについて
nwiizo
5
2.1k
技術的負債解消の取り組みと専門チームのお話 #技術的負債_Findy
bengo4com
1
1.2k
関東Kaggler会LT: 人狼コンペとLLM量子化について
nejumi
3
460
『衛星データ利用の方々にとって近いようで触れる機会のなさそうな小話 ~ 衛星搭載ソフトウェアと衛星運用ソフトウェア (実物) を動かしながらわいわいする編 ~』 @日本衛星データコミニティ勉強会
meltingrabbit
0
120
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
90
5.8k
We Have a Design System, Now What?
morganepeng
51
7.4k
Unsuck your backbone
ammeep
669
57k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.4k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
630
A Tale of Four Properties
chriscoyier
158
23k
How to Ace a Technical Interview
jacobian
276
23k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
12
950
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
20
2.4k
A better future with KSS
kneath
238
17k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
Transcript
Git and Github eddiekao@NCKU
None
Current Status 80% iOS app, 20% Ruby/Rails
Before we start..
You may create lots of files day by day..
edit them, save, edit them, and save.. x N
Backup?
Ctrl-C + Ctrl-V
"ProjectA" -> "ProjectA20130506" -> "ProjectA20130508-1" -> "ProjectA20130508-2" -> "ProjectA-bak" ->
"ProjectA-forEddie"
backup and sync on LAN
Version Control
Subversion (SVN)
but the problem is..
when network or svn server is down..
Is there any better way..?
Git
What's Git?
Version Control System (VCS)
created by Linus Torvalds for managing Linux kernel source code
in 2005
distributed
remote, and also local
Git
Git != Github
Why version control?
backup just like you can load saving data while playing
RPG game
history and evidence you know whom to blame when something
is going wrong :)
Why Git?
free
fast & smaller footprint
http://git-scm.com/book/en/Getting-Started-Git-Basics some other version control system..
http://git-scm.com/book/en/Getting-Started-Git-Basics git
just snapshots, not differences
local commit and remote push
most of the operations are local
easy to co-work with others
But..
git is easy to use, but hard to master
Install Git
on Mac: > brew install git on Ubuntu or some
linux OS: > sudo apt-get install git-core or > sudo apt-get install git
Exercise: please install git in your machine.
How to Git
configurations
.gitconfig it should locate in your home directory
set your username and email > git config --global user.name
"eddie" > git config --global user.email "
[email protected]
" list all settings > git config --list
make some useful aliases
[alias] co = checkout br = branch aa = add
--all l = "!source ~/.dotfiles/.githelper && pretty_git_log" https://github.com/kaochenlong/eddie-dotfiles
Exercise: 1. set your username and email for git. 2.
edit the ".gitconfig" and add some aliases.
.gitignore https://github.com/github/gitignore
don't be afraid of command line tools
git init
Exercise: please create a new directory and initialize for git
version control.
git clone
git clone git://github.com/kaochenlong/eddie-vim.git
Exercise: please try to copy a project from Github or
somewhere to your local machine.
working, staging, and repository
http://git-scm.com/about/staging-area
git add can add a single file or all modified
files, even a single line.
Exercise: add a new file named "hello.rb" and add to
staging area.
Exercise: after adding "hello.rb" to staging area, then try to
modify it and see what happen?
git status
Exercise: try to check if "hello.rb" is in staging area,
and then remove it from staging area.
git mv
Exercise: add "hello.rb" to staging area, and then rename it
to "world.rb".
git commit
Exercise: just commit it :)
When to make a Commit?!
commit message matters!
amend committed message
git commit --amend
Exercise: you just committed with a rubbish message, pleases amend
it to make sense for your project.
Exercise: in last commit, you forgot to add another file,
but you don't want to commit again just for this single file, please try to commit it with -- amend.
Notice: empty folder won't be committed!
if you still want to commit an empty folder, you
can put an empty “.gitkeep” file in it by convention.
git log
git log --pretty=oneline
git log --pretty=format:"%h %s"
git help log
Exercise: check your commit log
Exercise: read the help manual of “git log”, and make
your prefer log format.
Exercise: modify something in the "world.rb" then commit again.
git rm
Exercise: remove a file and then checkout it back.
git tag
tag is a milestone
Exercise: create a tag for your project
git branch
branching is very cheap
When to make a Branch?!
git checkout
Exercise: 1. create a new branch name "fruit" 2. checkout
to "fruit" branch 3. add a "banana.rb" and commit it
Exercise: please try to list all branches, including local and
remote branches.
Exercise: you accidentally delete the "world.rb" file, please try to
recover it with git commands.
Exercise: you just create a tag name “ncku”, try to
checkout to this tag after several commits.
git merge
conflict?
Exercise: 1. checkout back to "master" branch 2. merge "fruit"
to "master" 3. remove "fruit" branch if you like
git reset soft v.s. hard
Exercise: reset a file to untracked status which you just
added to staging.
Exercise: you just merged a branch, please try reset it
to back to un-merged branch.
git pull
git pull = git fetch + git merge
git push
git push origin ncku-branch
git clean remove untracked files
git stash apply, pop, list, clear
git remote
Reading References
1. Pro Git 2. ihower's blog http://ihower.tw/git/
Git Flow
http://git-scm.com/book/en/Git-Branching-Branching-Workflows
http://nvie.com/posts/a-successful-git-branching-model/
on Mac: > brew install git-flow on Ubuntu or some
linux OS: > sudo apt-get install git-flow https://github.com/nvie/gitflow/wiki/Installation
Exercise: please install git flow in your machine, and initialize
a git flow project.
init a project with git flow > git flow init
Branches Master, Develop, Feature, Release, Hotfix
add a new feature: > git flow feature start my_new_feature
when done with the new feature: > git flow feature finish my_new_feature
Exercise: your boss ask you to add a new feature
which can let user upload their photos, please try to finish this assignment in git flow.
Exercise: your boss find a bug and ask you to
fix it ASAP, please try to do this assignment in git flow.
Github
What's Github?
a git repository server
coders' facebook :)
None
make friends with other awesome coders :)
resume for coders!
Free? Price?
SSH/HTTPS/GIT
How to Github?
Exercise: register a new account on Github
without password?
SSH Key
Exercise: generate a SSH key pair in your local machine
and add the public key to Github
Exercise: create a new repository on Github
git push
Exercise: upload your project to Github
Exercise: 1. clone a project from Github 2. do some
changes 3. commit and push back to Github
Exercise: 1. create a new local branch 2. add some
change and then push this branch to Github
tag won't be pushed to repo by default
push a tag: > git push origin v2.0 push several
tags: > git push origin --tags
Exercise: create some tags for your project and upload them
to Github
git pull
Fork
Pull Request
Exercise: 1. fork a project from your classmate who is
sitting just next to you. 2. add some change and commit. 3. fire a pull request.
Github Pages
host static files for FREE
upload files via git commands
User pages kaochenlong.github.io
Project Pages gh-pages branch
custom domain name
Exercise: 1. create a github page for your account. 2.
set your domain name in CNAME if you have one.
something else?
bitbucket free private repo
git + dropbox
What's inside the .git folder?