some git util for vim
if you like my work, check here for a list of my vim plugins, or buy me a coffee
use Vundle or any other plugin manager is recommended
Plugin 'ZSaberLv0/ZFVimGitUtil'
Plugin 'tpope/vim-fugitive' " optional, for :ZFGitRebase only
-
:ZFGitPushQuickly[!] [comment]
"stash > pull > unstash > commit > push" quickly
usage:
cd
to a git repo:ZFGitPushQuickly[!] [commit message]
- show commit info before actually perform, unless the
<bang>
token!
is set - if
[commit message]
omitted,g:ZFGitPushQuickly_defaultMsg
would be used
features:
- all changed and added files would be committed
- if conflicts, push would abort, and conflicted files would be opened automatically
- user name/email/password would be saved temporarily, stop input them repeatly like a nerd
note:
- only http(s) repo is directly supported:
http(s)://user(:pwd)@server.xx(:port)/path
- ssh repo is not directly supported:
(ssh://)user@server:/path
- to support ssh repo:
-
on YourClient:
ssh-keygen
-
on YourClient:
ssh-copy-id -i ~/.ssh/id_rsa.pub -p 22 YourServerUserName@YourServerDomain
-
make sure it works before actually use quick push:
git fetch --all
, if fetch success without password required, then you are done
-
-
:ZFGitBatchFetch
/:ZFGitBatchPull
/:ZFGitBatchPush [comment]
find and go through all git repo under cwd, and try to fetch/pull/push
to filter out some unexpected repo:
function! YourFilterFunc(repoPath) " return 1 if the repo should be filtered return 0 endfunction let g:ZFGitRepoFilter = { \ 'YourModuleName1' : '\<_repo\>', \ 'YourModuleName2' : function('YourFilterFunc'), \ }
-
:ZFGitClean
fill a temp file with untracked and ignored files, save the temp file to remove all of these files
-
:ZFGitFetch
quickly fetch from remote, and prune local and remote merged branches
-
:ZFGitCheckout
quickly switch between branches
-
:ZFGitMergeToAndPush
merge current branch to specified branch, push, then go back to current branch
-
:ZFGitRemoveBranch
remove branch from remote and local quickly
-
:ZFGitRebase
perform 'git rebase -i' inside vim, require
tpope/vim-fugitive
-
:ZFGitStatus
find and go through all git repo under cwd, echo its changes by
git status -s
-
:ZFGitConflictOpen
/:ZFGitConflictResolve
util to open or resolve conflict files
-
:ZFGitMirror
config git mirror quickly
-
:ZFGitHardRemoveAllHistory
/:ZFGitHardRemoveFileHistory
like the name, use with caution
-
NOTE: github would no longer support plain password push method (
https://YourName:YourPlainPassword@github.com/xxx
), you must use access token for now, see here for more info, and see below for how to use the access token for short
-
to make things more convenient and more safe, it's recommended to setup access token
-
private repos are also supported, but your access token must have push permission to your private repos, otherwise, this confusing error message may occur:
remote: Repository not found. fatal: repository 'https://YourName@github.com/YourName/YourRepo/' not found
- for public repos, check
Access public repositories
would be fine - for private repos, you must check
Full control of private repositories
- for public repos, check
-
-
we are trying hard to make
ZFGitPushQuickly
more quickly, the git user name/email/password are detected automatically with these order:-
your custom setting
let g:zf_git = [ \ { \ 'repo' : 'https://github.com/YourName/YourRepo', " match by string compare \ 'repo_regexp' : 'github\.com', " match by regexp `match()` \ \ 'git_user_email' : '', \ 'git_user_name' : '', \ 'git_user_pwd' : '', " optional \ }, \ ]
-
git config user.name
/git config user.email
to check from local repo -
your global custom setting
let g:zf_git_user_email = '' let g:zf_git_user_name = '' let g:zf_git_user_pwd = '' " optional
-
git config --global user.name
/git config --global user.email
to check from git global setting
-
-
the
git_user_pwd
mentioned above, can be your git password, oraccess token
mentioned above -
the email and user name would be saved to
git config
of local repo, the password would be saved temporarily until vim exit -
by default, we would apply some git configs to local repo config:
let g:zf_git_extra_config = [ \ 'git config core.filemode false', \ 'git config core.autocrlf false', \ 'git config core.safecrlf true', \ ]
-
ZFGitPwdSet(git_remoteurl, git_user_name, git_user_pwd)
update the password stored by
ZFGitPushQuickly
, cached in memory until vim exit, set emptygit_user_pwd
to remove saved password -
ZFGitPrepare(options)
prepare necessary git info
options:
-
module
: module name, ZFGit by default -
needPwd
: whether need pwd, false by default -
confirm
: whether need confirm, true by default -
extraInfo
: extra info when confirm, empty by default -
extraChoice
: extra choice options{ 'key1' : 'text1', 'key2' : 'text2', }
return:
choice
: y/extraChoicegit_remoteurl
git_pushurl
git_user_email
git_user_name
git_user_pwd
-
-
ZFGitGetInfo()
return current git config (see
ZFGitPushQuickly
above)return:
git_remoteurl
git_pushurl
git_user_email
git_user_name
git_user_pwd
-
get various info
ZFGitGetRemoteUrl()
ZFGitGetCurCommit()
ZFGitGetCurBranch()
ZFGitGetAllLocalBranch()
ZFGitGetAllRemoteBranch()
ZFGitGetAllBranch()
ZFGitGetAllConflictFiles()
-
command line complete
ZFGitCmdComplete_branch
ZFGitCmdComplete_branch_remote
ZFGitCmdComplete_branch_local
ZFGitCmdComplete_changedPath