2018年5月24日 星期四

MySQL Command

安裝  mysql client
$sudo apt-get install mysql-client-5.7
' install

登入
$mysql -h 172.21.2.171 -u root -p
'mysql >
'check account  'root'@'%'

使用系統資料庫(切換schema)
mysql>use mysql ;

server 有多少帳號
mysql>select @@version;
mysql>select user,host  from mysql.user;

mysql>show databases;
'DB
mysql> use piwik;
mysql>show tables;


建立 user
mysql>create user 'matomouser'@'localhost' IDENTIFIED BY 'usermatomo';
'注意, 記得client重新連線

mysql> grant select on piwik.* to 'matomouser'@'%'; 'read

建立資料庫
mysql>create database cljdb default character set utf8 collate utf8_bin;
mysql> grant all on cljdb.* to 'clj'@'%' with grant option;

查看表格設計
mysql>describe first_table;

個人操作改密碼
mysql>set password for 'matomouser'@'localhost'='usermatomo'




git command

https://backlog.com/git-tutorial/tw/stepup/stepup1_1.html

https://git-scm.com/book/zh-tw/v2/%E9%96%8B%E5%A7%8B-%E5%88%9D%E6%AC%A1%E8%A8%AD%E5%AE%9A-Git

git 指令網址 https://git-scm.com/docs

切換git local預設目錄(default)到所要的目錄(clj/Agile_Coach)
$git cd \clj\Agile_Coach

設定遠端登入帳號
git config --global user.name "cljclj2000"
## origin 代表目前目錄
## HEAD 表示目前進行中Working File 所在的Branch(Version)

**將local 目錄 設定到 remote 上
$git remote add cljclj2000  http://github.com/cljclj2000/firstgit.git
$git push -u clj master

**新開發的第一件事
把Remote firstgit目錄 clone 一份到目前目錄,在 local 開發
$git clone http://github.com/cljclj2000/firstgit.git

檔案有任何動作,需加入Stage 再  commit
$git add .
'將異動增加入 git stage



發生衝突
$git push  http://github.com/cljclj2000/firstgit.git master
' Fail
$git pull  http://github.com/cljclj2000/firstgit.git master

修改錯誤檔案內容
$git add .
$git commit -a -m "merge"
$git push -u clj master

回到上一版
method 1:
$git revert HEAD
$git reset  --hard HEAD~

查看local 狀態
$git status
'目前local 有無動作



知道版別的異動狀況
$git log --graph --oneline

要進行開發,先確認目前版本是不是最新的
$git fetch origin master <--檢remote差異,
$git checkout FETCH_HEAD
$git diff master
============================
查看本地分支情況
$git branch --list

產生新分支
$git branch 20191229 master  <== 新的分支 20191229


切換分支
$git checkout a1
切換到 a1 分支

刪除分支
$git branch -d issue2

放棄已經變動的檔案
$git status
modified:   Dockerfile
$git reset --hard

刪除目錄
$git rm -rf docker_1\
delete ...
$git add .
$git commit -m 'delete docker_1'
$git push origin master <--傳回remote

完成檔案工作,合併回master
$git checkout branch_aaa
$git add .
$git commit -a -m 'check-in message'
$git checkout master
$git merge branch_aaa
$git branch -d branch_aaa
$git push origin master

===================================================
基本的branch 說明
https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging

===================================================
Q0 : 重新安裝如何設定
step1. complete Q1 action 
step2. set file default path 
  1. In Windows 10, search for Git Bash
  2. Click on Open File Location
  3. In the folder that opens, right click on Git Bash and click Properties
  4. Go to the Shortcut tab
  5. Remove the –cd-to-home from the Target field
  6. Put the start path you want in the Start in field
  7. Hit Apply
Q1: github 啟動 2FA  , git bash 不能pull,push

step1.
參考 https://blog.miniasp.com/post/2016/02/01/Useful-tool-Git-Credential-Manager-for-Windows
先移除window 中 github 帳密 (搜尋列 : 管理網路密碼)







step2.
參考 https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line
產生通行碼







Step3
$git pull origin master
username: cljclj2000
passowrd <-- 貼上通行碼

Q2:如何忽略work directory 的檔案 (例如暫存檔),存進去git?
Step1 . 在目前的專案目錄下,新增 .gitignore
Step2. $ vim .gitignore
*~
Step3. 存檔

Q3 : 如何知道目前的master 與前一commit 的差異?
$git diff --name-status HEAD^ HEAD(以這一版為Base做比較)
     2_2_1_Create_Great_Team/2_2_1_3_SelfSelection.odp 新增

A       2_2_1_Create_Great_Team/SpotifyScaling.pdf 新增

Q3.1 如何知道某一個commit  與特定 commit 的差異 ?
Step1.
$git log
commit 9689a7ff6fe75ce3a0fdd25da543b320166e439e (HEAD -> master, origin/master)
Author: cljclj2000 <cljclj2000@gmail.com>
Date:   Tue Dec 3 12:25:18 2019 +0800
    20191203
commit 9eed5eb676d1a40a6982d56934c93beb9b72fee6
Author: cljclj2000 <cljclj2000@gmail.com>
Date:   Mon Dec 2 17:30:38 2019 +0800
    20191202
commit 1fc68dfacdf7799335bac102bbe0821613b8560f
Author: cljclj2000 <cljclj2000@gmail.com>
Date:   Fri Nov 29 12:03:08 2019 +0800
    20191129
Step2.
$git diff --name-status 1fc68dfacdf7799335bac102bbe0821613b8560f   9689a7ff6fe75ce3a0fdd25da543b320166e439e
M       2_2_1_Create_Great_Team/2_2_1_2_AgileSelfOrg.odp
A       2_2_1_Create_Great_Team/2_2_1_3_SelfSelection.odp

A       2_2_1_Create_Great_Team/SpotifyScaling.pdf

Q4 : 將目前的檔案已異動全部放棄 ?
$ git add .
$ git reset --hard


2018年5月10日 星期四