GithubHelp home page GithubHelp logo

don't use index about vim-gitgutter HOT 7 CLOSED

airblade avatar airblade commented on August 24, 2024
don't use index

from vim-gitgutter.

Comments (7)

airblade avatar airblade commented on August 24, 2024

I'm not sure I understand completely...do you want to compare HEAD with your working tree?

If so, what's the difference between git diff-index -M HEAD and git diff HEAD?

from vim-gitgutter.

zander avatar zander commented on August 24, 2024

Short version; the diff-index skips the index.

Long version;
try this;

  1. edit a (previously committed) file, deleting some lines or adding some.
  2. Use 'git add ' on it.
  3. Open same file agan and edit it some more.

Using 'git diff' you will see the changes you made in step 3, not the changes you made in step 1.
Using 'git diff-index -M HEAD -U3' you will see the differences accumulated of stuff you did in step 1 and AND step 3.

I think the latter (the diff-index) is more correct as thats the changes made since you last committed.

I personally think that the vast majority of git users work around the index and try to avoid things like 'git reset'/'git add' etc. Thats naturally not a scientific fact, but my experience. At minimum when I teach git to people I tell them to avoid it, as its really not easy to grasp the concept of an invisible version of your file thats in the index IMOHO.
As such I think this is great thing to avoid surprises by those users.

from vim-gitgutter.

airblade avatar airblade commented on August 24, 2024

OK, I see the difference between git diff and git diff-index -M HEAD -U3. But I don't see any difference between the latter and git diff HEAD...?

The reason I prefer git diff HEAD to git diff-index -M HEAD -U3 is the former is possible right now with vim-gitgutter.

from vim-gitgutter.

zander avatar zander commented on August 24, 2024

I think you are right that there is no difference, you could make my change simpler by just using 'diff HEAD' in there.

It looks like two correct solutions to my problem that currently gitgutter doesn't show changes made before a 'git add'.
Not sure if I understand your stentence '..the former is possible right now with vim-gitgutter'. I probably missed something :)

from vim-gitgutter.

airblade avatar airblade commented on August 24, 2024

I think adding this to your vimrc will do the trick:

let g:gitgutter_diff_args = 'HEAD'

from vim-gitgutter.

zander avatar zander commented on August 24, 2024

After updating my gitgutter git repo to HEAD, and adding that line, it seems to work as expected :)

lots of changes in this project!

from vim-gitgutter.

airblade avatar airblade commented on August 24, 2024

Glad it's working for you!

Lots of changes, yes, though it's settling down now :)

from vim-gitgutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.