- Workspace:工作区
- Index / Stage:暂存区
- Repository:仓库区(或本地仓库)
- Remote:远程仓库
请根据以上图标理解git的使用,然后用git --help查看需要用的命令,相信会容易理解一些。
常用的命令:
git clone 'url'
git checkout '仓库名'
git status
git add
git commit 'xxxxxxx'
git push origin '仓库名'
git pull origin '仓库名'
git remote -v 显示远端仓库完整路径
git reset --soft <commit_id> 回退到指定commit,保留代码
git reset --hard <commit_id> 回退,不保留代码
git stash 暂存当前分支的修改
git stash pop 恢复当前分支的修改
git checkout 文件名 恢复本地删除的文件
git checkout . 恢复当前目录
删除新增的文件夹和文件,恢复环境:git checkout . && git clean -xdf
清除add的部分:git reset . && git checkout
添加个人信息:
git config --global user.name [username]
git config --global user.email [email]
配置commit模板
git config --global commit.template <模版文件路径(例如x/xx/template.txt)>