## Git 指令 - [回去 Git 幼幼班](/pCUxppstSkmjGbqRrJH8mw) ### :pencil2: 目錄與文件 | **指令** | **說明** | **DEMO link** | **範例** | |:--------------- |:---------------- |:------------- |:---------------- | | cd | 切換目錄 | | `$ cd D:/` | | pwd | 顯示目前位置 | | | | ls | 列出資料夾的明細 | | | | mkdir | 新增資料夾(目錄) | | `$ mkdir GitHub` | | git init | 接管資料夾 | | | | git st (status) | 看目前文件狀態 | | | | git mv | 變更檔名 | | `git mv index.html hello.html` | ### :spades: push & pull | **指令** | **說明** | **DEMO link** | **Note** | |:---------- |:---------------- |:------------- |:---------------------------------------------------------------------- | | git push -u origin main| 推送到 main 分支 | | | | | | | | | | | | | ### :spades: add & commit | **指令** | **說明** | **DEMO link** | **Note** | |:---------- |:---------------- |:------------- |:---------------------------------------------------------------------- | | git add | 將文件存到暫存區 | | `$ git add XXX.html``$ git add *.html` `$ git add --all` `$ git add.` | | git commit | 存檔並留言 | | `$ git commit -m "版更詳細"` | | | 分支 | | | ### :wrench: 常用指令 | **指令** | **說明** | **DEMO link** | **Note** | |:---------- |:---------------------- |:------------- |:---------------------------------------------------------------------- | | echo | 建立一個文件並輸入內容 | | `$ echo "hello.git" > welcome.html ` | | touch | 建立一個文件 | | `$ touch index.html` | | git rm | 請 git 幫我刪檔案 | | 文件會到暫存區 `$ git rm index.html` | | --cached | 不給 git 控管 | | tracked > untracked `$ git rm xxx.html --cached` | ### :mag: History查詢 | **指令** | **說明** | **Platform** | **Note** | |:------------------------- |:------------------------- |:------------:|:------------------------------------------------------------------- | | git log | 查看 commit 記錄 | | | | --author | 找 commit 作者 | | `$ git log --oneline --author="chloe\|ted"` | | --grep | 找 commit 內容 | | `$ git log --oneline --grep="abc"` | | -S | 找符合條件的檔案 | | `$ git log -S "hello"` | | --since、--until、--after | 找時間日期內全部的 commit | | `$ git log --oneline --since="9am" --until="6pm" --after="2023-01"` | | | | | |
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up