The code is here. Just put this in your .vimrc and you should be ready to
go.
"
" Function that automatically adds, commits and pushes changes to git
repository
" It is based on the VCSCommand plugin
"
function Repo()
" pull the changes from the remote repository to check for conflicts
:call RepoPull()
" open a new tab with the same filename as the tab from which this command
" was run - to prevent tampering with the splitted windows of the current
tab
:silent tabnew %
" edit the current directory
:edit .
" add and commit all the files in the current directory to the repository
:VCSAdd
:VCSCommit automatic commit message
" close the current tab since we don't need it anymore
:tabclose
" push the added and committed files to repository
:call RepoPush()
endfunction
"
" Push the current working directory to repository
"
function RepoPush()
:! git push origin master
endfunction
"
" Pull from remote repository
"
function RepoPull()
:! git pull
endfunction
Then you just need to do :Repo and it will pull the contents from the remote
repository, add and commit all the files, and push the changes.
Tell me what do you think about the solution. Do you see any errors ...
anything that could be better?
P.s.: I'm opening a new tab, because I the VCSAdd opens a splitted window if
some file needs to be added, but it doesn't open a splitted window if
there's no files to be added. So I cannot just simply solve that with a :q
... that's why I added a new tab.
Thanks it.
--
View this message in context: http://vim.1045645.n5.nabble.com/VCSCommand-push-pull-tp4564092p4567724.html
Sent from the Vim - General mailing list archive at Nabble.com.
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment