git
fugitive
git
|
fugitive
|
action
|
git add %
|
:Gwrite
|
Stage the current file to the index
|
git checkout %
|
:Gread
|
Revert current file to last checked in version
|
git rm %
|
:Gremove
|
Delete the current file and the corresponding Vim buffer
|
git mv %
|
:Gmove
|
Rename the current file and the corresponding Vim buffer
|
git diff %
|
:Gdiff
|
resolving merge conflicts with vim's diffget and diffput
|
git edit %
|
:Gedit
|
resolving merge conflicts with vim's diffget and diffput
|
:Glog
|
load all previous revisions of the current file into the quickfix list
|
:Glog -10
|
load the last ten previous revisions of the current file into the quickfix list
|
:Glog -10 --reverse
|
load the first ten revisions of the current file into the quickfix list (in reverse chronological order)
|
:Glog -1 --until=yesterday
|
load the last version of the current file that was checked in before midnight last night
|
:Glog --
|
load all ancestral commit objects into the quickfix list
|
:Glog -- %
|
load all ancestral commit objects that touched the current file into the quickfix list
|
操作步骤
:Gwrite
:Gcommit
:Gpush
:Git add assets/map.png
:Git add assets/*.*
查看修改的文件列表
:Git diff --stat --name-only
:help fugitive 帮助文档
:Gread
:Gwrite
:Gcommit -m 'reset ip'
:Gpush origin master
二进制文件
:Git add src/assets/clothes.png
~/.gitconfig
[alias]
co = commit
br = branch
test/.gitignore
*.bak
!keep.bak #不忽略keep.bak
/node_modules/*
!/node_modules/twig/
!/node_modules/layer/layer.js
temp/ # 忽略temp目录下的所有目录和文件
temp/*/ # 忽略temp目录下的所有目录,但不会忽略该目录下的文件
git add vimrc
git commit -m 'add vimrc config'
git push origin master
git log --pretty=oneline #查看提交的历史记录
git reset --hard HEAD^ #退回一步
git reset --hard 994b0 #退回到指定位置
git reflog #查看提交和退回历史命令
git checkout -- vimrc #丢弃工作区的修改
git rm test.txt #删除文件
git commit -m 'remove test.txt'
创建远程仓库
git remote add origin git@github.com:marsnut/test.git
git push -u origin master #第一次推送加参数-u,关联本地和远程mater分支
git checkout -b dev #创建并切换分支
git branch dev #相当于这两条命令
git checkout dev
git branch #查看分支
git merge dev #合并到master分支
git branch -d dev #删除dev分支
git branch -D dev #强制删除dev分支
通常合并分支时,git会用'fast forward'模式,删除分支后,会丢掉分支信息
git merge --no-ff -m 'merge with no-ff' dev #--no-ff表示禁用'fast forward'
git remote -v #查看远程分支
git tag ???
git fetch #将远程仓库代码下载到本地,默认origin分支
git fetch dev #将dev分支下载到本地
git fetch -p #清理远程仓库已经清理的分支
git pull #远程下载并合并分支
相当于
git fetch + git merge FETCH_HEAD
git del README.md #删除当前文件
git del README.md --cached #从版本库中删除文件,但不删除当前文件
git checkout -- READDME.md #撤销修改,从版本库中恢复