git常用指令记录
git指令个人记录
初始化:
git init [可选,新建目录] 初始化
git clone [ssh地址] 从服务器克隆,常用
git设置
git config --[local|global] --list 列出本地/全局设置
git config --[local|global] [user.name|user.email|...] [更改结果] config更改
远程仓库连接
git remote add origin 远程地址 关联远程仓库
git remote 查看本地添加了哪些远程分支地址
git remote -v 查看本地添加了哪些远程分支地址更详细信息
git remote remove origin 删除本地指定的远程地址
分支
git branch [branch-name] 创建分支
git branch 查看当前分支
git branch -a 查看本地和远程的所有分支
git branch -r 查看远程所有分支
git branch -d [branch-name] 删除一个分支
git branch -D [branch-name] 强制删除一个没有合并的分支
git branch --set-upstream-to=origin/[branch-name] [branch-name] 把本地分支和远程分支进行连接
撤销add
git reset HEAD -- .
git reset HEAD -- filename
git rm --cached filename
常用操作
git add 提交暂存区
git commit -m ['commit message'] 提交本地仓库
git push origin branch:branch(左边为被拉取)
git pull origin branch:branch(左边为被拉取)
git checkout 暂存区覆盖工作区
git checkout [branchname] 切换分支