配置
- 配置用户名:
git config --global user.name "your name"; - 配置用户邮箱:
git config --global user.email "youremail@github.com"; 删除
git push origin --delete [branchname]
提交
- 提交工作区所有文件到暂存区:
git add . - 提交工作区中指定文件到暂存区:
git add <file1> <file2> ...; - 提交工作区中某个文件夹中所有文件到暂存区:
git add [dir]; 撤销
- 删除工作区文件,并且也从暂存区删除对应文件的记录:
git rm <file1> <file2>; - 从暂存区中删除文件,但是工作区依然还有该文件:
git rm --cached <file>; - 取消暂存区已经暂存的文件:
git reset HEAD <file>...; - 撤销上一次对文件的操作:
git checkout --<file>。要确定上一次对文件的修改不再需要,如果想保留上一次的修改以备以后继续工作,可以使用stashing和分支来处理; - 隐藏当前变更,以便能够切换分支:
git stash;