Questions tagged [git-stage]

Git staging area or Git index is a list of files that will go to the next commit. Use this tag for questions about problems and operations with the staging area.

The staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit. It’s sometimes referred to as the “index”, but it’s also common to refer to it as the staging area. (from Pro Git)

Files are staged (indexed) with , or and removed from stage with . Actual contents of the staging area can be shown with .

Recommended questions:

three main sections of a Git project

99 questions
2560
votes
16 answers

How do I show the changes which have been staged?

I staged a few changes to be committed. How do I see the diffs of all files which are staged for the next commit? Is there a handy one-liner for this? git status only shows names of files which are staged, but I want to see the actual diffs. The…
Frerich Raabe
  • 90,689
  • 19
  • 115
  • 207
1144
votes
3 answers

Show git diff on file in staging area

Is there a way I can see the changes that were made to a file after I have done git add file? That is, when I do: git add file git diff file no diff is shown. I guess there's a way to see the differences since the last commit but I don't know what…
arod
  • 13,481
  • 6
  • 31
  • 39
618
votes
10 answers

Staging Deleted files

Say I have a file in my git repository called foo. Suppose it has been deleted with rm (not git rm). Then git status will show: Changes not staged for commit: deleted: foo How do I stage this individual file deletion? If I try: git add…
Andrew Tomazos
  • 66,139
  • 40
  • 186
  • 319
460
votes
10 answers

Git: list only "untracked" files (also, custom commands)

Is there a way to use a command like git ls-files to show only untracked files? The reason I'm asking is because I use the following command to process all deleted files: git ls-files -d | xargs git rm I'd like something similar for untracked…
We Are All Monica
  • 13,000
  • 8
  • 46
  • 72
237
votes
2 answers

Git list of staged files

I staged a lot of files using git add, and now I want to see all the files I have staged, without untracked files or changed, but unstaged files. How do I do that? When using git diff --cached I can see the changes of what I just staged. So then I…
Timon de Groot
  • 7,255
  • 4
  • 23
  • 38
75
votes
8 answers

Stage only deleted files with git add

I have run git status and see several modified files and several deleted files. Is it possible to stage only deleted or only modified files?
rok
  • 9,403
  • 17
  • 70
  • 126
50
votes
2 answers

Difference between stash vs stage files in GIT

When I need to save my changes from one branch before checking out to another branch, git sometimes says: stage or commit the files before you can checkout to another branch. But I have been recommended to use stash option so: Stage the files is…
fernando1979
  • 1,727
  • 2
  • 20
  • 26
41
votes
3 answers

How to undo the last commit in git, but keep my changes as unstaged?

I've made a commit, but now it is kind of difficult to see what I all changed. I can off course do a git diff, but I'd rather undo the last commit and keep all my changes in tact so that my IDE (PyCharm) simply shows me which files have been…
kramer65
  • 50,427
  • 120
  • 308
  • 488
25
votes
4 answers

Git: How to re-stage the staged files in a pre-commit hook

I'm writting a git pre-commit hook. The script could reformat some code, so it could modify the staged files. How can I re-stage all files that are already staged ?
tzi
  • 8,719
  • 2
  • 25
  • 45
15
votes
3 answers

Git: need to recursively 'git rm' the contents of all bin and obj folders

Someone by accident just commited all of their bin and obj folders to our repo (there are around 40 such folders). I would like to do a git rm -r on all of these folders. Is there a command to do this?
Jacko
  • 12,665
  • 18
  • 75
  • 126
15
votes
2 answers

Differences between the staged and unstaged versions of the same file, using difftool

Is there a way of viewing the differences between the staged and unstaged versions of the same file? For example: Changes to be committed: modified: conf/application.conf Changes not staged for commit: (use "git add/rm ..." to update…
DrKaoliN
  • 1,346
  • 4
  • 25
  • 39
14
votes
4 answers

VS Code stage changes shortcut

What is the VS Code stage changes shortcut? I mean is it possible to stage a selected file without clicking the plus button in the version control tab? Maybe there is no shortcut an it is somehow possible to setup one?
qqqqqqq
  • 1,831
  • 1
  • 18
  • 48
14
votes
4 answers

Git invert staging area

I have got changes in my staging area, and others not staged yet (some files have changes both in and out the staging area). I would like to invert the content of the staging area and the changes which are not staged. Does a shortcut exist in order…
moala
  • 5,094
  • 9
  • 45
  • 66
12
votes
5 answers

git undo deleted files

I am new to git. I have checkout files from remote. I had to delete few files from the git repo. Instead of doing git rm command, I issued unix rm -rf folder command. I need to revert the delete command and then perform git rm command. How to revert…
Pradeep
  • 753
  • 7
  • 15
  • 25
12
votes
2 answers

Git adding "unchanged" files to the stage

For a project I'm working on, I want to use: git add . -A to add some files to the stage. The problem is that Git thinks these files are unchanged from the last commit, so they are ignored. However, I personally changed the file, but Git still sees…
user2744374
  • 121
  • 1
  • 1
  • 3
1
2 3 4 5 6 7