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.

89 questions
1354
votes
8 answers

How to uncommit my last commit in Git

How can I uncommit my last commit in git? Is it git reset --hard HEAD or git reset --hard HEAD^ ?
richard
  • 13,881
  • 3
  • 18
  • 9
1001
votes
15 answers

What are the differences between "git commit" and "git push"?

In a Git tutorial I'm going through, git commit is used to store the changes you've made. What is git push used for then?
ben
  • 29,229
  • 42
  • 124
  • 179
655
votes
3 answers

Git - Difference Between 'assume-unchanged' and 'skip-worktree'

I have local changes to a file that I don't want to commit to my repository. It is a configuration file for building the application on a server, but I want to build locally with different settings. Naturally, the file always shows up when I do 'git…
ckb
  • 6,933
  • 3
  • 15
  • 11
652
votes
11 answers

Undo git update-index --assume-unchanged

I have run the following command to ignore watching/tracking a particular directory/file: git update-index --assume-unchanged How can I undo this, so that is watched/tracked again?
adardesign
  • 33,973
  • 15
  • 62
  • 84
228
votes
7 answers

What does the git index contain EXACTLY?

What does the Git index exactly contain, and what command can I use to view the content of the index? Thanks for all your answers. I know that the index acts as a staging area, and what is committed is in the index rather than the working tree. I…
mochidino
  • 3,463
  • 4
  • 23
  • 15
181
votes
3 answers

"git rm --cached x" vs "git reset head --​ x"?

GitRef.org - Basic: git rm will remove entries from the staging area. This is a bit different from git reset HEAD which "unstages" files. By "unstage" I mean it reverts the staging area to what was there before we started modifying…
Pacerier
  • 86,231
  • 106
  • 366
  • 634
76
votes
6 answers

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

What is the point of git add . or git add 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
  • 1,119
  • 3
  • 11
  • 22
58
votes
3 answers

How can you git add a new file without staging it?

To use git effectively (and as intended) I make small atomic commits, while I do have longer sessions where I do change not only one thing. Thus, I make heavy use of git add -p. This doesn't work for completely new files, though, because I tend to…
bitmask
  • 32,434
  • 14
  • 99
  • 159
42
votes
3 answers

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
  • 771
  • 2
  • 8
  • 14
35
votes
5 answers

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 okay. But everytime I switch the system, the git…
ramwin
  • 5,803
  • 3
  • 27
  • 29
30
votes
6 answers

Is the Git staging area just an index?

The book Pro Git says that the staging area is just a list, or index, that says which files will be committed when a git commit is done, and now the name index is more commonly known as the "staging area". But if we modify the file foo.txt that is…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
29
votes
2 answers

git checkout throws an error on --assume-unchanged files

After I run git update-index --assume-unchanged path/to/file on a particular branch, I'm unable to switch branches using git checkout. It throws the following error: error: Your local changes to the following files would be overwritten by…
Sujay
  • 2,198
  • 23
  • 32
27
votes
1 answer

git assume unchanged vs skip worktree - ignoring a symbolic link

I have a problems with a git repository and windows. The problem is that the git repository has a linux symbolic link in it and with developers running windows, that obviously does not work. Now since that symbolic link should never change, I want…
ryanzec
  • 27,284
  • 38
  • 112
  • 169
26
votes
1 answer

How to undo git update-index?

I just did the following to to keep a different copy of my config.php file in my localhost vs. my production environment: $ git update-index --assume-unchanged application/config/config.php Unfortunately, I didn't write the config.php file exactly…
tim peterson
  • 23,653
  • 59
  • 177
  • 299
25
votes
1 answer

Why staging directory is also called Index/Git Index?

I was confused the naming of staging directory (Git Index) in Git. Is there any special meaning such that it is called Index? Why not just called Cache / or Temp directory so that we can understand more easily? To me, index is sth which help us to…
TheOneTeam
  • 25,806
  • 45
  • 116
  • 158
1
2 3 4 5 6