git --version | 查看git的版本信息 |
git config --global user.name | 查看当前登录用户名 |
git config --global user.email | 查看当前登录邮箱 |
git config --global user.name Git账号 | 设置Git账号 |
git config --global user.email 邮箱地址 | 设置邮箱 |
git init | 在项目目录中创建新的 Git 仓库 |
git touch 文件名 | 新建文件 |
echo 'xxx' > 文件名 | 创建文件并写入内容xxx(> 表示写入,>>表示追加) |
git clone 仓库网址 | 克隆远程仓库到本地目录(第一次拉项目用,后面更新项目用git pull) |
git add . | 把所有文件添加到版本控制中或叫缓存区 |
git add xxx | 把文件xxx添加到版本控制中或叫缓存区 |
git rm xxx | 把文件xxx从版本控制中或叫缓存区中删除 |
git commit -m "版本更新内容说明" | 提交之前add的文件到本地仓库 |
git remote add origin 仓库网址 | 把本地仓库添加到缓存区 |
git push -u origin master | 将本地仓库新增或修改文件上传到远程仓库origin master |
git push -f origin master | -f = force commit 强制把本地仓库所有内容上传到远程仓库origin master |
git pull | 从远程仓库获取新数据 |
git log | 查看提交历史,与各次的提交说明 |
git branch xxx | 创建分支xxx |
git branch | 查看当前分支情况 |
git checkout xxx | 切换到分支xxx |
git merge xxx | 把当前的分支和xxx分支合并 |
git status | 查看当前路径下的状态 |
git remote add origin 仓库网址 | 关联远程仓库 |
git remote -v | 查看远程仓库信息 |
git remote rm 已关联的仓库缩写,如origin | 删除已有的GitHub远程仓库 |