git 初始設定

設定使用者訊息

$ git config --global user.name "xxx"
$ git config --global user.email "xxx@gmail.com"

查詢設定結果

$ git config --list

設定的值存在下列位置,更改該檔案之後 commit 的使用者訊息也會跟著改變

~/.gitconfig

 

git 建立

建立本地的 git

$ git init

拉遠端的 git

$ git clone remote_git_url

 

git 使用

查看當前 git 中的狀態:

查全部 $ git status    查特定資料夾 $git status "path"

加入新的檔案或是將修改後的部分進入 stage:

全部 $ git add .

單一 $ git add "path"

刪除 $ git rm "path"

提交修改:

全部 $ git commit

指定 $ git commit "path"

查看 log:

全部 $ git log

特定資料夾 $ git log "path"

連同修改的檔案資訊 $ git log --stat -v

顯示特定 commit 以前的 log $ git log "commit sha1"

查看 branch:

列出當前 branch $ git branch

列出所有 branch $ git branch -a

查看尚未 add 的修改:

查看當前目錄以下 $ git diff .

查看特定檔案 $ git diff "path"

查看 commit 的修改內容:

查看最後 commit 的修改內容 $ git show

查看指定 commit 的修改內容 $ git show "commit sha1"

查詢特定檔案的修改內容 $ git show "commit sha1" "path"

git checkout 用法:

切換到特定 branch $ git checkout "branch name"

切換回 master $ git checkout master

還原回 git server 上的特定檔案 $ git checkout "path"

git reset 用法:

將整個 project 中已經 stage 的檔案退回未 stage $ git reset --hard HEAD

特定檔案的改動從 stage 退回未 stage $ git reset HEAD "path"

退掉已經 commit 的改動 $ git reset --soft HEAD^

 

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 rex5405 的頭像
    rex5405

    雷射's zone

    rex5405 發表在 痞客邦 留言(0) 人氣()