git init 初始化git仓库 git clone url 复制一个仓库 git help 查看帮助
在提交以前,Git有一个暂存区(staging area),能够放入新添加的文件或者加入新的改动. commit时提交的改动是上一次加入到staging area中的改动,而不是咱们disk上的改动.
git add .
会递归地添加当前工做目录中的全部文件.
git add index.js 将index.js修改提交到本地暂存区 git add -A 提交全部变化 git add -u 提交被修改(modified)和被删除(deleted)文件,不包括新文件(new) git add . 提交新文件(new)和被修改(modified)文件,不包括被删除(deleted)文件
在git中,咱们使用git config 命令用来配置git的配置文件,git配置级别主要有如下3类:html
git config --(local/global/system) -l 查看仓库配置 git config --(local/global/system) -e 编辑仓库配置 git config user.name "tom" git config user.email "hhh@qq.com" git config --global alias.ci commit git config --global alias.a "add -A" // 别名配置 git config --global alias.a 'add -A' git config --global alias.b branch git config --global alias.c "commit -m" git config --global alias.ck checkout git config --global alias.st status
<ul> <li> %H 提交对象(commit)的完整哈希字串</li> <Li> %h 提交对象的简短哈希字串</li> <Li> %T 树对象(tree)的完整哈希字串</li> <Li> %t 树对象的简短哈希字串</li> <Li> %P 父对象(parent)的完整哈希字串</li> <Li> %p 父对象的简短哈希字串</li> <Li> %an 做者(author)的名字</li> <Li> %ae 做者的电子邮件地址</li> <Li> %ad 做者修订日期(能够用 --date= 选项定制格式)</li> <Li> %ar 做者修订日期,按多久之前的方式显示</li> <Li> %cn 提交者(committer)的名字</li> <Li> %ce 提交者的电子邮件地址</li> <Li> %cd 提交日期</li> <Li> %cr 提交日期,按多久之前的方式显示</li> <Li> %s 提交说明</li> </ul> // log美化 git config --global alias.lg "log --no-merges --color --graph --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Cblue %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit" // stash list 美化 git config --global alias.shs ' list --pretty=format:"%C(red)%h%C(reset) - %C(dim yellow)(%C(bold magenta)%gd%C(dim yellow))%C(reset) %<(70,trunc)%s %C(green)(%cr) %C(bold blue)<%an>%C(reset)"'
`Please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch。` 先按esc :wq 推出
readme.md .gitignore lisense
// 撤销demo.txt的修改(和上次commit的) git checkout demo.txt
git stash // 保存本地更改 git stash save -a "messeag" // git stash list git stash pop --index stash@{0} git stash apply stash@{id} //和pop同样,可是会保存stash记录 git stash clear // 清空 git stash drop // 删上一条
git checkout -b dev // 克隆远程分支建立本地dev git checkout -b dev origin/dev
git reflog //全部版本历史 git reset --hard hash
git clone -b dev ${url}
git br -D bambaoo
git br -vv
pick其中的一个分支的一次提交,合并到当前分支 git cherry-pick 08ru289
git commit --amend -m "update"
git checkout 5dc1bc214 templates/publish_advertisement.html
git config --system --unset credential.helper //长期存储密码: git config –global credential.helper store