Sublime Forum

Git integration - new files

#1

I just tried out build 3207 (on OS X 10.13.6) and the git integration feature is great. There’s one difference from the GitGutter plugin which I don’t understand.

When working with a new file (i.e. one that’s not in the git index nor part of any SHA), the diff seems to be against the file’s state the last time I started ST3. With git gutter, any new file will always show every line with a little green plus sign, because every line is new. With build 3207 I don’t understand what the integrated git is diffing against when working on a new file.

Regards,
Jeremy

0 Likes

#2

If files aren’t tracked by git directly, then the mini_diff functionality shows you changes made to the file since you last opened the file or first saved the file, whichever happened last.

For example, if you create a new tab and start typing, you don’t see any inline diff functionality because the file is not on disk yet. Once you save the file, when you make changes to it, the changes are tracked based on the file as it was the first time you saved it. As long as you keep editing the file, the diff still shows you changes based on that first save.

Similarly, if you close an untracked file and re-open it, no changes are indicated, but as you make changes, they will reflect the state of the file since you opened it; in order to reset the diff state you need to close and re-open the file.

For files that are tracked by git, the basis of the diff is either the head or the index, depending on how you set the git_diff_target setting. The default is "index", which as the name suggests tracks the index, in which case the diff only shows you unstaged changes; changing to "head" would show you all uncommited changes instead.

If desired, you can set mini_diff to "auto", which tells it to only show the mini diff on files that are tracked by git; in that case anonymous files will never show diff indicators in the gutter.

1 Like

#3

Thanks for the response, that makes sense.

I’d like to suggest a setting which allows untracked files (within a git-tracked folder) to have all of their lines shown as added in the gutter (the GitGutter plugin behaved this way and I found it quite helpful).

As it is, if I’m working on a tracked file and adding code (which comprises 95% of my day) :slight_smile: then I can see my additions in green. If I decide to move my new code to a separate file, all of a sudden I have no indicator, which feels quite inconsistent.

In general I’ve simply come to rely on the gutter to tell me what my uncommitted changes are.

I hope this makes sense and it’s great to see the integrated git support since git + ST3 tend to make up 100% of my days!

Jeremy

0 Likes