在安装完 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>