# GIT101筆記 ``` ##常用指令 初始化與複製專案 ## 初始化儲存庫 git init ## 在當前目錄下複製現有儲存庫 git clone <url> 新增與移除 ## 新增檔案至暫存區域 git add <file> ## 新增所有更改過的檔案至暫存區域 git add . ## 將檔案從暫存區域中移除 git reset <file> ## 將所有檔案從暫存區域中移除 git reset . ## 將所有已追蹤檔案還原 git reset --hard ## 將未追蹤檔案捨棄 git clean -f -d ## 提交並附上提交訊息 git commit -m "commit message" ## 修改提交訊息 git commit --amend ## 取消追蹤並刪除檔案 git rm <file> ## 取消追蹤檔案 git rm --cached <file> ## 取得提交內容並提交到當前分支 git cherry-pick <sha> ## 還原提交內容 git revert <sha> 檢查與比較 ## 查看當前檔案狀態 git status ## 比對工作目錄及暫存區域的差異 git diff ## 顯示提交歷史紀錄 git log ## 顯示 n 個提交歷史紀錄 git log -n ## 顯示提交內容 git show <sha> 遠端和更新 ## 顯示所有遠端儲存庫 git remote ## 顯示所有遠端儲存庫及 URL git remote -v ## 擷取所有遠端儲存庫 git fetch ## 擷取遠端儲存庫的 branch_name 分支 git fetch <branch_name> ## 擷取並合併遠端儲存庫 git pull ## 將當前分支上傳到遠端儲存庫 git push <remote_name> <branch_name> 分支與合併 ## 顯示本地所有分支 git branch ## 新增分支 git branch <branch_name> ## 刪除分支 git branch -d <branch_name> ## 強制刪除分支 git branch -D <branch_name> ## 更名分支 git branch -m <old_branch_name> <new_branch_name> ## 切換分支 git checkout <branch_name> ## 新增並切換至分支 git checkout -b <branch_name> ## 將 branch_name 合併到當前分支 git merge <branch_name> ```
×
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