git config --global user.name 'xxx' |
配置全局git提交用户名 |
git config --global xxx@xxx |
配置全局 git 提交邮箱 |
git config user.name 'Lee' |
配置当前git提交用户名 |
git config user.email '12345@qq.com' |
配置当前 git 提交邮箱 |
git init |
本地当前文件夹创建仓库 |
git init <文件名> |
当前文件夹下,新创建fileName文件夹来创建仓库 |
git clone <远程仓库地址> |
下载远程仓库地址库代码,分支为master分支 |
git clone <远程仓库地址> <本地文件夹名称> |
下载远程仓库地址代码,重新命名 |
git clone -b <指定分支名> <远程仓库地址> |
下载指定分支的远程库 |
git add <file> <file> |
添加多个文件到缓存 |
git add *.html |
将工作区中的所有.html文件添加到暂存区 |
git add . |
将工作区中所有未跟踪或者修改的文件添加到暂存区,并且会根据gitignore做过滤 |
git add * |
将工作区中所有未跟踪或者修改的文件添加到暂存区,开发中一般使用git add . |
git commit -m "msg" |
将缓存区内容添加到仓库中,msg为提交 |
git commit -am '版本描述' |
等同于git add all和git commit -m |
git status |
显示工作目录和暂存区的状态 |
git branch |
查看本地所有分支 |
git branch -r |
查看远端所有分支 |
git branch -a |
查看本地和远端所有分支 |
git branch <branchName> |
本地创建分支 |
git branch -d <branchName> |
删除本地分支 |
git checkout <branchName> |
切换分支 |
git checkout -b <branchName> |
创建分支并切换到新建分支 |
git branch -m <oldbranch> <newbranch> |
修改本地分支名 |
git reset --hard <xxx> |
回退 到某个提交ID或者标签 |
git remote add origin <你的远程仓库地址> |
本地仓库链接到远程仓库 |
git push -u origin master |
本地代码推送到远程代码库,加了参数-u后,以后即可直接用git push 代替git push origin master |
git fetch origin master |
将远程主机的最新内容拉到本地,不进行合并 |
git merge <branchName> |
branchName 分支和当前分支进行合并 |
git merge --continue |
合并冲突,修改完冲突文件之后调用git add . 然后再执行git merge --continue 继续执行merge操作 |
git pull origin master |
则是将远程主机的master分支最新内容拉下来后与当前本地分支直接合并 fetch+merge |
git log |
查看所有提交记录 |
git tag |
列出已有的标签 |
git tag <tagName> |
打标签 |