在安裝完 Git 以後,須要運行如下兩句命令git
git config [--global] user.name "John Doe" git config [--global] user.email johndoe@example.com
若是不想每次 pull|push 操做都輸入用戶名、密碼則添加如下設置bash
git config [--global] credential.helper store
新建倉庫:fetch
建立一個目錄,在目錄中執行url
git init
克隆倉庫: spa
git clone <remote|local> [pathname] remote: 遠程庫地址 local: 本地庫地址 pathname: 檢出路徑(默認爲當前目錄)
文件狀態:命令行
Untracked: 未跟蹤code
Unmodified: 未修改rem
Modified: 已修改it
Staged: 已暫存ast
將未跟蹤(Untracked)或已修改文件(Modified)放入暫存區(Staged):
git add <.|pathname>... .: 全部文件 pathanme: 文件路徑
將暫存區(Staged)的文件保存(未修改狀態:Unmodified)
git commit <-m message> -m message: 本次提交信息
一、分支新建:
git branch <branch_name>
二、分支切換:
git checkout <branch_name>
三、分支列表:
git branch [-a]
四、分支重命名:
git branch (-m | -M) [<oldbranch>] <newbranch>
五、分支合併:(將指定分支合併到當前分支)
git merge <branchname>…
六、分支刪除:(將被合併的分支刪除)
git branch (-d | -D) [-r] <branchname>…
一、查看遠程庫
git remote [-v | --verbose]
二、添加遠程庫:
git remote add [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=<fetch|push>] <name> <url>
三、重命名遠程庫分支
git remote rename <old> <new>
四、刪除遠程庫
git remote remove <name>
git pull <remote:branche> <local_branche>
git push [-u] <remote:branche> <local_branche>