初始化
git config --global user.name "user"
git config --global user.email email@com
git config --global credential.helper store
git config --global --list
新建仓库
git init
git clone url
工作区和文件状态
- 工作区
- 暂存区
- 本地仓库
添加和提交
gir status
git add file
git add *.txt //通配
git add . //文件夹的全部文件
git commit -m "commit info"
git log
git log --oneline //简洁
回退版本
git reflog id
查看差异
git diff //默认比较工作区和暂存区
git diff id1 id2 //比较两个版本
git diff HEAD~ HEAD //比较上一个版本和当前版本
删除
rm file.txt
git ls-files
git rm file
删除过后需要提交
忽略文件.gitignore
SSH配置
ssh-keygen -t rsa
远程仓库和本地仓库
//step1
git remote add <远程仓库名> <远程仓库地址>
//step2
git push -u <远程仓库名> <分支名>
gir remote -v
git pull <远程仓库名><远程分支名>:<本地分支名>
分支
git branch
git branch name
git checkout branch
git switch branch
git merge branch
git log --graph --oneline --decorate --all
git branch -d branch