Commit 283f408b authored by Moritz Sokoll's avatar Moritz Sokoll 💬
Browse files

added some commands

parent e48f7e8b
......@@ -2,13 +2,20 @@
## a simple git integration for vim
`vim-git-control` provides simple integration for committing, pushing and checking out branches for git within vim
## Installation
preferred use is with [plugin-manager]( Just download the `git-control.vim` and move it into
`~/.vim/plugins`. Then add the plugin to your plugins list.
### [plugin-manager](
Download the `git-control.vim` and move it into `~/.vim/plugins`. Then add the plugin to your plugins list.
### Other
Download the file and move it to some path. Then add `source /path/to/git-control.vim` to your `.vimrc`
## Usage
`vim-git-control` comes with a few commands:
`vim-git-control` comes with some commands:
- `:GitCommit`: prompts the user for a commit message and commits
- `:GitPush`: prompts the user for a remote (defaults to origin) and pushes to that remote
- `:GitCheckout`: prompts the use for a branch to checkout to
- `:GitStatus`: shows the git repository status
- `:GitBranch`: creates a new branch
- `:GitLog`: shows a git commit log
- `:GitInit`: initalize an empty git repository
- `:GitRemoteAdd`: add a new remote
- `:GitStage <file>`: stage a file/folder
- `:GitUnstage <file>`: unstage a file/folder
- `:GitRemotes`: show remotes
......@@ -12,7 +12,7 @@ function! Git_Commit()
if len(commit_message) < 1
echo 'message too short'
let stat = system("git commit -am '" . commit_message . "'")
let stat = system("git commit -m '" . commit_message . "'")
echo stat
......@@ -63,10 +63,43 @@ function! Git_Log()
echo system('git --no-pager log --pretty=oneline --graph')
command! GitCommit call Git_Commit()
command! GitPush call Git_Push()
command! GitCheckout call Git_Checkout()
command! GitStatus call Git_Status()
command! GitBranch call Git_Branch()
command! GitLog call Git_Log()
function! Git_Init()
echo system('git init')
function! Git_Remote_Add()
let remote_name = input('remote name: ')
let remote_url = input('remote url: ')
if len(remote_name) < 1 || len(remote_url) < 1
echo 'remote name and remote url must be at least one character long'
elseif matchstr(remote_name, ' ') == ' ' || matchstr(remote_url, ' ') == ' '
echo 'remote name and remote url cannot consist of spaces'
echo system('git remote add ' . remote_name . ' ' . remote_url)
function! Git_Stage(filename)
echo system('git stage ' . a:filename)
function! Git_Unstage(filename)
echo system('git restore --staged ' . a:filename)
function! Git_Remotes()
echo system('git remote')
command! GitCommit call Git_Commit() " commit staged changes
command! GitPush call Git_Push() " push
command! GitCheckout call Git_Checkout() " checkout to another branch
command! GitStatus call Git_Status() " show the git status
command! GitBranch call Git_Branch() " create a new branch
command! GitLog call Git_Log() " show the commit log
command! GitInit call Git_Init() " initalize a git repository
command! GitRemoteAdd call Git_Remote_Add() " add a new remote
command! -nargs=1 -complete=file GitStage call Git_Stage('' . <f-args>) " stage a file/folder
command! -nargs=1 -complete=file GitUnstage call Git_Unstage('' . <f-args>) " unstage a file/folder
command! GitRemotes call Git_Remotes() " show remotes
let g:git_control_loaded = 1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment