1.git init 初始化git仓库 .git是git的版本库,存放stage的暂存区,分支
2.git status 查看仓库状态
3.git add 添加文件到仓库
4.git commit -m file 提交到仓库 git add实际是把文件添加到暂存区,git commit实际是把暂存区的文件提交到当前分支master
5.git diff file 查看文件内容
6.git log 查看历史记录
7.git reset --hard HEAD^ 回退到上一个版本 HEAD^^(上上个版本),如果回退版本过久HEAD~100
8.git reset --hard commit id 指定回退到某个版本,commit id 可以通过 git log 查看或git reflog
9.git checkout -- file 恢复文件在工作区的修改
10.git rm file 从版本库删除文件
11.git push -u 将本地所有内容推送到远程库
12.git remote add origin git@server-name:path/repo-name.git 关联一个远程库
13git clone https://github.com/account-name/repo-name.git 从远程库克隆到本地
14.git checkout -b 创建新分支
15.git branch 查看当前分支
16.git merge 合并分支
17.git branch -d 删除分支
18.git switch -c 创建新分支
19.git switch 切换分支