Questions tagged [git-index]

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.

Filter by
Sorted by
Tagged with
1 vote
2 answers
65 views

Pop conflicting Git stash while keeping stash index

Explanation: I make a heavy use of Git staging area to keep track of the changes that I'm already sure of while the working directory is often a mess of untested solutions, TODOs and a code that is ...
Piotr Siupa's user avatar
  • 4,058
1 vote
0 answers
103 views

Removing a submodule manually

I tried removing manually the following submodule from my local repository: components/CtrlFuelSuppHtr Removed it from these three places: .git folder, components folder, and deleted it on .gitmodules....
tadm123's user avatar
  • 8,434
3 votes
0 answers
289 views

Git: Could not reset submodule index when checking out

I'm trying to checkout a specific commit ID along with all its submodules. git checkout --recurse-submodules 7fdb9221d958acda289904951fe6d37873e8cfbf But I'm getting the following error: fatal: not a ...
tadm123's user avatar
  • 8,434
0 votes
1 answer
55 views

For a given Git repository, how do I find the path to its index file?

Suppose that I am running a script inside a Git repository and want to access the index file directly. How can I get the path to the index file, in a way that also respects e.g. worktrees?
Waleed Khan's user avatar
  • 11.4k
4 votes
1 answer
271 views

How can I recover from "invalid sha1 pointer in resolve-undo" with git fsck?

I run git gc in a repository and get a fatal error: Enumerating objects: 2382, done. Counting objects: 100% (2382/2382), done. Delta compression using up to 8 threads Compressing objects: 100% (747/...
Joe's user avatar
  • 29.9k
0 votes
0 answers
16 views

Restore git index to it's previous state after mistakenly invoking git read-tree

While resolving merge conflicts I accidently executed git read-tree which broke my index. As I'm still on porcelain level I'm not sure what happened and if it's restorable. Can I get back to my ...
qesterius's user avatar
1 vote
0 answers
31 views

Weird behavior of git switch/checkout if index has same content as target commit [duplicate]

Let's create a small local repository: git init echo foo > foo git add foo git commit -m foo git branch bar echo foo >> foo git commit -a -m 'another foo' If we do this now, we replace our ...
Michi's user avatar
  • 701
0 votes
0 answers
434 views

git error: read error while indexing: Invalid argument

I'm initializing a repo in a Google Drive folder which contains a gsheet file. When I index the folder this error happens: git add . error: read error while indexing file.gsheet: Invalid argument ...
Ooker's user avatar
  • 2,190
1 vote
1 answer
130 views

How can navigate one level back at the git interactive staging (add) command

After running the interactive staging git command $ git add -i and choosing one of the options for example "update", then I don't know how to get back to the root level to choose another ...
muel's user avatar
  • 53
3 votes
1 answer
173 views

Is it possible to apply single lines from stash?

I'm looking for a way to include specific parts of stashes in stage. I'm using TIG frontend, so the method can involve some low level offset, etc. calculation. However currently I don't have any idea ...
psprint's user avatar
  • 349
0 votes
1 answer
379 views

How can I directly and quickly change all the uid/gid of all files in the git index of a git repository

My use case is that I have a very large GIT repository created by uidA:gidA with all its files and git index as uidA:gidA That I have snapshoted/frozen using netapp file system technology aka froze ...
Sarvi Shanmugham's user avatar
3 votes
1 answer
598 views

Why does git checkout file behave like reset staged file followed by checkout unstaged file?

I've come across this statement in git documentation: Checking out a file is similar to using git reset with a file path, except it updates the working directory instead of the stage Link:https://www....
caffein's user avatar
  • 313
5 votes
1 answer
778 views

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 <file>..." to unstage) (use "git add <file>..." to mark resolution) ...
Enlico's user avatar
  • 24k
0 votes
2 answers
90 views

Why does `git update-index` not affect files not in the current directory?

I'm trying to use git update-index --again to re-add modified files to the index. This works fine, but only for files/directories in the current directory. Is this expected behavior for this command ...
planetp's user avatar
  • 14.7k
0 votes
0 answers
30 views

Cloning a git repo that will be the upstream parent but I want to make changes to the README for my new project and not ever push that back

I want to base my new project off of an existing git repo. My intention is not to extend the current project but to start a new project with different aims. Specifically I want to remove the original ...
Evolve's user avatar
  • 8,989
1 vote
2 answers
423 views

How does Git restore index and wokring directory internally (upon reset/checkout)?

I understand that when I checkout or reset --hard to a specific commit/branch then I get the relevant contents in my working directory and the index file. But how does Git internally re-build the ...
caffein's user avatar
  • 313
0 votes
2 answers
102 views

Git index file not identical after resetting back - why?

I'm trying to understand how the git index file works. I have a local repository with some files, one of them test.txt. I was on commit X and saved the index file of that commit to a temp directory. ...
caffein's user avatar
  • 313
38 votes
6 answers
16k views

git forces refresh index after switching between Windows and Linux

I have a disk partition (format: NTFS) shared by Windows and Linux. It contains a git repository (about 6.7 GB). If I only use Windows or only use Linux to manipulate the git repository everything is ...
ramwin's user avatar
  • 5,893
2 votes
1 answer
219 views

libgit2-newbie question: What goes in the file tree in a commit?

tl;dr: libgit2-newbie gets confused about indexes in coding commits, eventually decides to ignore the index and just update the commit tree. Please advise if this is wrong. This is a (libgit2-newbie) ...
Martin Ellison's user avatar
1 vote
1 answer
126 views

Undo "git update-index --assume-unchanged" is not working (in conjunction with --no-skip-worktree)

I have read Undo git update-index --assume-unchanged file, but alas, nothing does work: whatever/.idea > git ls-files -v S ant.xml I tried: git update-index --no-assume-unchanged --no-skip-...
GhostCat's user avatar
  • 138k
0 votes
1 answer
1k views

Undo git update-index --no-assume-unchanged (not working) and be able to see these local changes again

Update: My permissions issues somehow fixed themselves arbitrarily as now the exact same remote branch create command works, so (as you probably guessed) it wasn't caused by this tracking issue. Now ...
salemandreus's user avatar
4 votes
2 answers
842 views

Why does git make new blobs between 'git add' commands?

So I've recently discovered the tool git cat-file and I've been playing around with it. I know that git uses blobs to store the actual content. But why does it seem to create a new blob every time I ...
Donald's user avatar
  • 713
3 votes
3 answers
724 views

Why does Git need to design Index /Stage?

The following image is Git flow diagram, I'm very strange why Git need to design Index /Stage. You know the communication between Repository and Workspace is local, it's easy to commit or rollback ...
HelloCW's user avatar
  • 1,003
1 vote
1 answer
713 views

Git - Have untracked files in online repository [duplicate]

I'm using git (bitbucket) to source control my linux configuration files. All the files are in the directory ~/.cfg/. Then I additionally have some local configuration files in ~/.cfg/local/ which are ...
Mate de Vita's user avatar
  • 1,114
1 vote
1 answer
574 views

diff does not contain new files

I am working on a project which uses git. Whenever I make changes, I submit a patch to the main developer who apply and commit it. Things worked nicely this far whith: git diff > somepatch.patch ...
LightSith's user avatar
  • 845
1 vote
1 answer
258 views

understanding git reset effect on index

I'm having a small conflict when reading documentations/tutorials about git reset: For git reset --mixed for example, the documentation says: The next thing reset will do is to update the Index ...
Zizou's user avatar
  • 873
3 votes
2 answers
985 views

What is ctime and mtime used for in the git index?

When a file is added to the index for the first time the file’s create timestamp is stored in the index record's ctime and the file's current modified time stamp is stored in the mtime field. When ...
Rich Shealer's user avatar
  • 3,402
0 votes
1 answer
81 views

Git commit -a is showing all files as deleted

I believe some of the people might have encountered this similar issue. Suddenly, when I do git commit -a, it states that all my files are deleted and I need to add them back in. Based on some of ...
user1805458's user avatar
  • 1,091
78 votes
6 answers
51k views

What's the use of the staging area in Git?

What is the point of git add . or git add <filename> to add it to the staging area? Why not just git commit -m "blabla"? I don't understand the value of the staging area.
itsolidude's user avatar
  • 1,159
1 vote
1 answer
35 views

Add a file to a Github repo that will be cloned, but not tracked

I feel like this question must have been asked before, but I'm not finding it on here. I have a file that I want in a GitHub repo, in this case a file in which the user would paste their API keys ...
jwong1219's user avatar
1 vote
1 answer
143 views

Bad index file while in shared directory

I use an Ubuntu VM over Windows 8 using VMWare and while using git I got an error of error: bad index file sha1 signature fatal: index file corrupt When trying to commit. Now, I found ways to fix ...
Neo's user avatar
  • 3,616
0 votes
1 answer
122 views

various git states, low-level understanding of git status (head, index, working states)

Imagine you have one tree with one file. Suppose we have only two possible states for this file, a, and b. If it's missing or not-existent, ø. I'm trying to build a table to understand all the ...
pyramation's user avatar
  • 1,641
0 votes
2 answers
345 views

How to stage subsequent changes to a file that has already been staged in index?

I made some changes to a file and then staged it in the index for the next commit. Then I realized that I needed some more changes to do. Instead of unstaging it, is there a way to capture these ...
Mohammad Ali Asgar's user avatar
0 votes
1 answer
31 views

How to clear blobs under git/objects after resetting INDEX on initial commit?

In a clean git repo, if I add all untracked files using git add . then git stores all files as blobs under git/objects directory. Now if I remove files from Index back to working directory using git ...
dkjain's user avatar
  • 841
42 votes
3 answers
13k views

How to recover `.git/index` locally?

I accidentally deleted .git/index, is there a way to recover it? It's permanently deleted. I haven't committed anything yet.
dyarbrough's user avatar
6 votes
2 answers
648 views

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 ...
LeGEC's user avatar
  • 47.6k
1 vote
2 answers
108 views

Why isn't it sufficient to just stage work-in-progress before switching branches? Why must I also commit?

I'm working on some files in one branch (called big_new_feature). The files are not ready to commit, but I need to switch branches to make a quick fix in another branch (called stable_branch). Why can'...
osullic's user avatar
  • 563
5 votes
3 answers
250 views

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 ...
Marecky's user avatar
  • 1,954
3 votes
2 answers
785 views

Show files that are in Git's index and changed in the working copy

I have a Git pre-commit hook which strips whitespace and leaves the modified files in the working copy, so that it doesn't stomp on a partial add like git add -p. If I commit one file out of many ...
Inductiveload's user avatar
2 votes
1 answer
398 views

Ignore local changes in the file and update it on pull

We have a repo with a file say x.APK that is pulled by client machines. These client machine will modify this file and keep it locally for their use. In normal usage we will update this file very ...
goldsmit409's user avatar
3 votes
2 answers
1k views

git - revert update-index/ignored file so I can change branch?

I was trying to add an error log to my .gitignore file, and somewhere along the way read that I had to specifically untrack the file after adding it to .gitignore. Somehow, I wound up using this to ...
jleach's user avatar
  • 7,490
14 votes
1 answer
7k views

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 ...
PyRulez's user avatar
  • 10.6k
0 votes
1 answer
146 views

If my staging index is empty, why is `git rm` deleting a file that isn't there?

According to the git rm documentation, this is how it behaves: Remove files from the index, or from the working tree and the index If I just did a commit and my index is empty, executing git rm ...
Steve's user avatar
  • 4,476
1 vote
0 answers
30 views

How does staging a file modify the index file internally?

git index(.git/index) stores the state of tracked files (last committed state) and it can be shown via git ls-files --stage and git diff looks at the difference between index and working directory. ...
Boon's user avatar
  • 40.9k
2 votes
1 answer
2k views

Keep ignored files when switching branches in git

Eclipse has it's own files .project, .classpath and .settings folder. In git, I have them in the .gitignore file, because I don't want them to be tracked in the remote repository. My problem is that ...
carcaret's user avatar
  • 3,278
0 votes
1 answer
39 views

how to remove untrack changes but keeping indexed changes

in my git status I see this Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: file1 modified: file2 modified: file4 Changes not staged for commit: (use "git ...
user2167582's user avatar
  • 6,106
3 votes
1 answer
3k views

How to start tracking directories/files again which were removed from git index?

Using below command i removed few directories from git index: git rm -r --cached <your directory> Now how can i add those untracked directories to git index again?
learner's user avatar
  • 796
0 votes
2 answers
65 views

How many versions of a file are kept in git when that file is modified?

So I am reading the Version Control with Git, 2nd Edition and I stumbled on this paragraph (page 51, section "Using git add") Most of the day-to-day changes within your repository will likely be ...
matori82's user avatar
  • 3,729
4 votes
2 answers
10k views

Why does checkout sometimes stage a file?

When I first started using Git, I found the checkout command quite confusing. However, as I adapted to Git's model of version control, it started to make sense. Now I am having to teach Git to my ...
Keith Pinson's user avatar
  • 7,845
4 votes
2 answers
2k views

Why is the git index file binary?

Most of the files in my Git directory are plain text files (except for the compressed loose objects and the packfiles). So I can just cat and edit files like .git/HEAD or .git/refs/heads/master and ...
das_j's user avatar
  • 4,494