将远程仓库项目克隆到本地
git clone http://xxx.git
初始化配置
git config --global user.name "ABC"
git config --global user.email ABC@example.com
git config --list
初始化仓库
git init
CURD(增删改查)
在工作目录中新增文件
git status
git add ./
git commit -m "详细说明"
在工作目录中删除文件
git rm 要删除的文件
git status
git commit -m "详细说明"
git mv 老文件 新文件
git status
git commit -m "详细说明"
在工作目录中修改文件
git status
git add ./
git commit -m "详细说明"
在工作目录中查询文件
git status : 查看工作目录中文件的状态(已跟踪(已提交 已暂存 已修改) 未跟踪)
git diff : 查看未暂存的修改
git diff --cache : 查看未提交的暂存
git log --onelin : 查看提交记录
分支
git log --oneline --decorate --graph --all : 查看整个项目的分支图
git branch : 查看分支列表
git branch -v : 查看分支指向的最新的提交
git branch name : 在当前提交对象上创建新的分支
git branch name commithash : 在指定的提交对象上创建新的分支
git checkout name : 切换分支
git branch -d name : 删除空的分支 删除已经被合并的分支
git branch -D name : 强制删除分支
使用频率最高的五个命令
git status 跟踪
git add 添加
git commit 提交
git push 推送
git pull 拉取