Git

By SunTalk

2019/2/26

  • What is Git

  • Git Basic

  • Advanced Git

  • GitHack && Lab

What is Git

What is Git

  • Linus Torvalds 創造
  • 一種版本控制系統

Classification

  • 本地端 (Local Version Control)
  • 集中式 (Centralized Version Control)
  • 分散式 (Distributed Version Control)

LVC

CVC

DVC

Git?

  • Local Version Control ?
  • Centralized Version Control ?
  • Distributed Version Control ?
  • Local Version Control ?
  • Centralized Version Control ?
  • Distributed Version Control ?

Download

Git Basic

GitHub

GitHub

1.取個自己喜歡的名子

2.這個打勾

3.按下去

Use GitHub

cd Desktop
git clone https://github.com/SunTalk/UVA.git 

Use Git

cd Desktop
mkdir <FileName>
cd <FileName>
git init
git config --global user.name "<Name>"
git config --global user.email "<Email@gmail.com>"
  • 設定個人資訊

Tree

Status

Untracked files

Changes not staged for commit

Changes to be commited

Commited

Use Git

git status
git add <FileName>
git commit -m "<Your commit>"

最基本最重要的指令

GitHub同場加映

git pull
git push

Git Log

git log
git log --oneline
git log --grep="<Want to Find>"
git log --author="<Name>"
git log --oneline --grep="<Want to Find>"
git log --oneline --author="<Name>"

Git Log

git log --pretty=format:"%h - %an, %ar : %s"
git log

Gitk

Reset

git reset --soft HEAD~
git reset --mixed HEAD~
git reset --hard HEAD~
git reset <SHA1>
git reset 9e5e6a4

Git diff

git diff <SHA1>

git diff <SHA1> <SHA1>

Ignore File

在目錄底下新增 .gitignore

  • *.exe
  • *.out

常用的 gitiginore 大集合

https://github.com/github/gitignore

Advanced Git

Git Branch

git branch <YourNewBranch>
git checkout <YourNewBranch>

git checkout -b <YourNewBranch>

Git Merge

git checkout master
git merge hotfix
git branch -d hotfix
git branch -D hotfix

Git Merge

git checkout master
git merge iss53

Merge Conflicts

Git Remote

git clone <SSH/HTTPS>

Git Remote

git fetch <remote>

git pull

git push <remote> <branch>

Resource

Resource

GitHack && Lab

GitHack && Lab

  • .git檔
  • 數據庫中的機密資料
  • 管理者留的後門
  • 非開源原始碼

解決辦法:

  • 單獨部屬
  • 限制權限
  • 限制訪問
  • 直接刪掉

Lab time

flag 形式:

NISRA{XXXX}

Level One

在commit中留下的訊息

Level Two

use reset

Level Three

只有一個branch嗎?

謝謝大家~

(๑•̀ㅂ•́)و✧