Skip to content

Latest commit

 

History

History
1100 lines (776 loc) · 22.2 KB

denny.md

File metadata and controls

1100 lines (776 loc) · 22.2 KB

title: Git output: denny.html

--

Git


Denny Huang

2015/4/25

--

Who am I ?


Denny Huang

--

Survey

--

是否寫過程式?

--

小專題/中大型
專案開發經驗

--

版本控制經驗

--

Shell 熟悉程度

--

Git / GitHub

It's different

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

Source:  Code Smart, Don't Code hard  by 畢玉泉(CrBoy)<[email protected]>

--

攻城屍的救星

版本控制

--

版本控制類型

--

本地端版本控制


--

集中式版本控制系統


--

分散式版本控制系統

--

事前準備

  • 註冊 GitHub 帳號
  • 確認已安裝 Git
    • 在 Terminal 輸入 git 確認
    • sudo apt-get install git
    • sudo yum install git
  • 選擇輔助武器 - 編輯器 (vim, emacs, gedit)

--

環境設定

git config --global user.email "[email protected]"

git config --global user.name "Your Name"

git config --global color.ui true

git config --global core.editor vim

--

環境設定

git config --global alias.co commit

git config --global alias.lg "log --color --graph --all --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"

--

.gitconfig

Why --global?

--

Practice

Create a new repo on GitHub

--

Public / Private

--

README.md

--

.gitignore

--

License

--

Practice

Delete the repository

--

Practice

Create an new repo without initialization

--

Practice

Create a new local repository

--

git help <command>

--

git init

--

Practice

Add file to staging area

--

back

--

touch README.md

--

git status

--

Add file to staging area

  • git add README.md

  • git add .

--

.gitkeep

--

Unstage file

  • git reset <file>



img

--

Practice

Commit to repository

img

--

Before commit

  • git status

  • git diff

  • git diff --cached

--

Commit

  • git commit

  • git commit -m "first commit"

--

何時該 commit?

--

commit log 怎麼寫?

yo

--

git commit -a

--

--

Practice

Show commit message

--

Show commit log

  • git log

  • git show <revisions>

--

SPECIFYING REVISIONS

--

Practice

Untrack / Rename file

--

Remove file

  • git rm <file>

Untrack file

  • git rm --cached <file>

--

Rename file

  • git mv <file>

--

Practice

Back to the past

--

Checkout to previous version

  • git checkout <revision>

Checkout file from previous version

  • git checkout <revision> <file>

--

Stash files

  • git stash

  • git stash save "message"

  • git stash list

  • git stash pop

  • git stash show -p <revision>

--

Reset to previous version

  • git reset <revision>

  • git reset --hard <revision>

--

Revert commit

  • git revert <revision>

--

Practice

Push to remote server

--

Add remote repo

  • git remote add origin https://github.com/denny0223/workshop.git

  • git remote

  • git remote -v

  • git remote show origin

--

--

Push to remote repo

  • git push -u origin master

  • git push origin master

  • git push

  • push.default

--

List branches

  • git branch

  • git branch -a

  • git branch -v

  • git branch -vv

--

Cache https password

git config --global credential.helper cache

git config --global credential.helper "cache --timeout=3600"


--

Practice

Clone your repo via ssh

try to commit and push

--

git clone

--




Please make sure you have the correct access rights

and the repository exists.

--

--

Practice

Pull from remote repo

Resolving conflict

--

Add a new commit at remote via https repo.

--

git pull

git fetch + git merge

--

Merge conflict

git mergetool

--

git pull --rebase

--

Branch

--

--

Practice

Create a branch

--

Create a branch

  • git branch <branch name>

  • git checkout -b <branch name>

--

Practice

commit and push new branch to remote

--

Push when local and remote branch name difference

  • git push <remote> <local_branch_name>:<remote_branch_name>

--

Git Flow

--

--

Practice

merge branches

--

Merge

  • git merge

  • git merge --no-ff

--

剩下就是你們的事了

--

Something useful

--

Something useful (cnt.

Just for fun

--

Show branch names in $PS1

Halloween Bash Profile Generator

function parse\_git\_branch {
   git branch --no-color 2> /dev/null | sed -e '/^[^\*]/d' -e 's/* \(.*\)/(\1)/'
}

export PS1="\h:\W \u\$(parse_git_branch)$ "

--

Resources

--

Resources (cnt.

--

10 year

--

Thanks for listening!