0%
git
1 2 3 4
| git init git add . git commit -m "comment..." git pull
|
实用命令汇总
工作区 -> 暂存区
暂存区 -> 本地仓库
1
| $ git commit -m "some info"
|
本地仓库 -> 远程仓库
1
| $ git push origin master
|
工作区 <- 暂存区
1
| $ git checkout -- <file>
|
暂存区 <- 本地仓库
本地仓库 <- 远程仓库
1 2 3 4
| $ git clone <git_url> $ git fetch upstream master $ git pull upstream master $ git pull --rebase upstream master
|
工作区 <- 本地仓库
1 2 3 4
| $ git reset <commit> $ git reset --mixed <commit> $ git reset --soft <commit> $ git reset --hard <commit>
|
配置实用参数选项
全局配置
用户信息
1 2
| $ git config --global user.name "your_name" $ git config --global user.email "your_email"
|
文本编辑器
1
| $ git config --global core.editor "nvim"
|
分页器
1
| $ git config --global core.pager "more"
|
别名
git config --global alias.gs "git status"shell
纠错
1
| $ git config --global help.autocorrect 1
|
个人配置
不加–global参数的话,则为个人配置
1 2 3
| $ git config --list $ git config user.name $ git config user.name "your_name"
|
如果在项目中设置,则保存在.git/config文件里面
1 2 3 4 5
| $ cat .git/config [user] name = "your_name" ......
|