Also known as staging area, this is where Git keeps changes made to versioned files and what it uses when it creates a new node in history graph (when you do a commit). This is also the reason why git add is so important, as it adds changes to staging area.
Questions tagged [git-index]
89 questions
19
votes
2 answers
Who touched my git assume-unchanged bit?
I have a certain file in my repo that I have set the assume unchanged bit on:
git update-index --assume-unchanged someFile.txt
Once in a while, after some work on the repo, that bit is unset and the file is automagically not assume-unchanged…

Yuval Adam
- 161,610
- 92
- 305
- 395
16
votes
5 answers
Testing what is about to be committed in a pre-commit hook
When a pre-commit hook runs, the repository might not be clean. So if you naively run your tests, they will not be against what you're committing, but whatever happens to be in your working tree.
The obvious thing to do is to git stash --keep-index…

pwaller
- 601
- 6
- 10
14
votes
1 answer
How does `receive.denyCurrentBranch=updateInstead` interact with the Index?
The receive.denyCurrentBranch config option controls what happens if you push to a repo's branch that is checkout.
By default, it rejects it (which is why you usually only push to bare repos, which have no checkout branches).
It can be disabled…

PyRulez
- 10,513
- 10
- 42
- 87
10
votes
2 answers
Where does "git update-index --assume-unchanged file" actually save this information to?
I like to modify config files directly (like .gitignore and .git/config) instead of remembering arbitrary commands, but I don't know where Git stores the file references that get passed to "git update-index --assume-unchanged file".
If you know,…

Mauvis Ledford
- 40,827
- 17
- 81
- 86
9
votes
4 answers
What is the difference between the working directory and the git Index?
The git book defines the git index:
The Git index is used as a staging
area between your working directory
and your repository. You can use the
index to build up a set of changes
that you want to commit together. When
you create a commit,…

WinWin
- 7,493
- 10
- 44
- 53
8
votes
2 answers
Git: How does git remember the index for each branch?
For example, I create file a in the repo(suppose I'm on the master branch),
then I git add a and git commit.
After that I git branch copy and git checkout copy.
Finaly I create file b in the word directory then git add b.
Git seems to be smart when…

Determinant
- 3,886
- 7
- 31
- 47
7
votes
2 answers
How to make a patch ignore the file index using "git apply"?
I'm trying to apply a .patch file to my source, but it fails because my file index (10655) is older than the patch index (10755).
Now I know that I can just modify the patch's file index but I would like to know if there is any way using git to…

Placeholder
- 4,651
- 6
- 33
- 35
7
votes
1 answer
How do contents of git index evolve during a merge (and what's in the index after a failed merge)?
I have a fuzzy idea of what the git index contains as one does git-adds and git-commits, but I don't have a clue of what happens to these contents when one does a git-merge. I'm particularly interested in learning what the index holds when a merge…

kjo
- 33,683
- 52
- 148
- 265
7
votes
2 answers
Git stash removes added changes
During development, I routinely add working versions of files (but not commit them) to my git repo. I continue to work on those files, till they reach commitable stage, when I can commit them. So the repo looks like below
$ git status
# On branch…

Anshul Goyal
- 73,278
- 37
- 149
- 186
7
votes
3 answers
Getting Git-concept of "stage"
Still having a hard time getting my head wrapped around the concept of staging as it applies to Git.
Can any analogies be made with SVN?
What is the primary purpose of having a stage level in Git?

Bachalo
- 6,965
- 27
- 95
- 189
6
votes
2 answers
Is there a reflog for the index?
I do not have a specific problem at hand, but I have encountered in the past some cases where I accidentally blew up my index, and wished I could go back the the previous state of a given file, which was indexed at some point.
Some example cases are…

LeGEC
- 46,477
- 5
- 57
- 104
5
votes
1 answer
Can I mark a file for resolution without adding it to the index with one command?
When there's a conflict, git status shows this:
Unmerged paths:
(use "git restore --staged ..." to unstage)
(use "git add ..." to mark resolution)
both modified: some_file
Now I can git add some_file to mark resolution, as the…

Enlico
- 23,259
- 6
- 48
- 102
5
votes
3 answers
Why does the "git index" have so many names?
While reading how to use Git, I found a lot of different names for git index.
They were:
directory cache
current directory cache
staging files
staging area
How come there are so many options to name exactly one thing?
How I should to name it to…

Marecky
- 1,924
- 2
- 25
- 39
5
votes
1 answer
Ignore changes to a tracked file without making it impossible to `git add` the file
You may like to skip the preamble.
I have an npm package with the following structure:
lib/index.js
src/index.coffee
The source file is a CoffeeScript file. I have a make target for building the JavaScript file from the source file. Until recently…

davidchambers
- 23,918
- 16
- 76
- 105
5
votes
2 answers
How to stage line by line in git gui although "No newline at end of file" warning
I use git gui to select lines for being staged for a commit. This normally works like a charm. I am aware of the option to do the same on the command line.
Whenever a file does not initially have a new line at the end of the file git gui recognizes…

JJD
- 50,076
- 60
- 203
- 339