- 全局配置
git config --global user.name "FirstName LastName"
git config --global user.email first.last@163.com
git config --global core.autocrlf true (DO NOT SET ON UNIX)
git config --global push.default simple
git config --global http.sslVerify false
git config --global http.postbuffer 1048576000
- 文件查阅系列
- 查看某个文件的历史修改版本: git log --follow -p fileRelativePath
- stash系列,stash 针对整个分支
- stash: git stash / git stash save 'msg'
- stash pop: git stash pop
- 应用任意一次修改到当前目录 stash 内容不被pop出来 : git stash apply stash@{x}
- 列表:git stash list
- 清空:git stash clear
- 分支系列
- 删除本地分支:git branch -D branchName
- 创建并切换分支:git checkout -b branchName
- 切换分支:git checkout branchName
-
git推送本地分支到远程分支
- 远程先开好分支然后拉到本地
- git checkout -b feature-branch origin/feature-branch //检出远程的feature-branch分支到本地
- 本地先开好分支然后推送到远程
- 远程先开好分支然后拉到本地
$ git checkout -b feature-branch //创建并切换到分支feature-branch
$ git push origin feature-branch:feature-branch
//推送本地的feature-branch(冒号前面的)分支到远程origin的feature-branch(冒号后面的)分支(没有会自动创建)
文件历史差异查看
1、git log -- filename(git log filename)
可以看到该文件相关的commit记录
2、git log -p filename
可以显示该文件每次提交的diff
3、git show comit_id filename
可以查看某次提交中的某个文件变化
4、git show commit_id
查看某次提交