Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I commit files currently displayed in Vim with fugitive?

Tags:

I am editing files opened split into three windows. I want to commit those into the repository. Is there any commands to do that?

like image 481
katatagan Avatar asked Dec 07 '14 07:12

katatagan


People also ask

How do I see files committed in git?

Find what file changed in a commit To find out which files changed in a given commit, use the git log --raw command. It's the fastest and simplest way to get insight into which files a commit affects.

How do I commit files to a git repository?

To add and commit files to a Git repository Create your new files or edit existing files in your local project directory. Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed.


1 Answers

There are a few ways to accomplish this task. I will outline the most interactive method which uses :Git.

  • Open up the status window via :Git
  • Move between files via <c-n>/<c-p>
  • Stage/unstage files via -
  • Start committing via cc whilst in the status window
  • Create commit message and save and close window. (I prefer :x)
  • You can also use zj and zk to move between sections
  • Using - on a section will stage/unstage all the files in that section

For more help with :Git see :h :Git or :G when in the :Git buffer.

Can use :Gwrite or :Gw and :windo to skip the :Git window to make this a bit faster.

:windo Gw
:Git commit

You can also skip the whole commit window by using the -m flag. e.g. :Git commit -m "A short message"

I recommend official repo on GitHub and Vimcasts videos on Fugitive: The Fugitive Series - a retrospective

To learn more see:

:h fugitive
:h :Git
:h :Gw
:h :Git commit
:h :windo
:h :x
like image 115
Peter Rincker Avatar answered Sep 19 '22 15:09

Peter Rincker