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
1
vote
1 answer

Revert previously staged changes (or: undo changes to .git/index)

When trying to understand the ways to undo various git operations I came up with a scenario where I'm not sure how to deal with it. Disclaimer: I did not have this situation when actually working with git 'in production' but I'd still think it's not…
mvo
  • 1,138
  • 10
  • 18
1
vote
1 answer

ignore all changes to dir

We have a git submodule, it's in a folder called 'config' in several repos. I am getting this when doing a merge: On branch oleg/feature/1537299444 Your branch is up to date with 'origin/oleg/feature/1537299444'. Changes not staged for commit: …
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
1
vote
3 answers

Remove staged file and reset to original version

If I have a file in the staging area (showing in git diff --cached) and I want to remove it completely how do I do that? Doing git reset HEAD -- file git checkout -- file does it but is there 1 command for these 2 actions?
Jim
  • 3,845
  • 3
  • 22
  • 47
1
vote
3 answers

git: How to stage/commit another changeset while currently already have something staged

this happens quite often to me: After a day of coding i start to stage relevant changes for a feature. I do this mostly by "git add -p" to selectively add only relevant changes (keep debug things and so on out). But then i realize that i also did…
Henning
  • 1,289
  • 2
  • 11
  • 25
1
vote
1 answer

libgit2: how to stage particular lines in a hunk

I am writing a mac application that will allow me to stage only the lines that contain particular text as substring. Basically I try to build that feature that source tree offers for its users. Staging selected lines in the hunks. My selection logic…
Selvin
  • 12,333
  • 17
  • 59
  • 80
1
vote
1 answer

Git doesn't stage my files any longer, and reports them as both "deleted" and "untracked". Why is that, and how to avoid it?

I have been successfully working on a simple git repo, with 4 files, adding and committing them many times. But lately, any time I try to add some of them, then ask for status, git reports all my files as deleted AND untracked. So I can not add my…
Fed Zee
  • 391
  • 3
  • 8
1
vote
1 answer

Determine if workdir has changes and index has staged changes (libgit2)

I've looked in repository.h, index.h and didn't found how to determine if workdir has any changes? And also, if index has any staged changes? I'm not interested in details, want just overall status.
Rob Luca
  • 153
  • 10
1
vote
0 answers

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. How does the use of git add to stage files modify…
Boon
  • 40,656
  • 60
  • 209
  • 315
1
vote
1 answer

Git fails to stage new folder because file "already exists in index"

With MinGW Git on Windows, I cannot add a new folder. It repeatedly fails, saying fatal: Will not add file alias 'newfolder/file.txt' ('newfolder/File.txt' already exists in index) I have attempted to look for the "existing" file with git ls-files…
Michael
  • 8,362
  • 6
  • 61
  • 88
1
vote
1 answer

why file in gitignore will be modified after android studio compile?

I have a file called VersionUtil and set it into the gitignore. In the gitignore file, I have # Git info app/src/main/java/com/test/util/VersionUtil.java Before I run the project in android studio, there's a line of code in VersionUtil.java: public…
Shumin Gao
  • 677
  • 2
  • 8
  • 15
1
vote
1 answer

“git rm .” is not adding the deleted files in the staged area

I eliminated some files of my project. I want to pass all the eliminated files to staging area with some as git rm ., but I want to pass all the files at once using wildcards. What's the good way to stage the eliminated…
daniel barrera
  • 347
  • 1
  • 4
  • 15
1
vote
1 answer

Git. Undo staged changes in working directory, keeping staged area untouched

Suppose I have staged a few changes: $ git diff --cached # few changes are stashed + change 1 new blabla - change 2 old + change 2 new blabla - change 3 old + change 3 new blabla $ git diff # no other changes Now I would like to test my…
klm123
  • 12,105
  • 14
  • 57
  • 95
1
vote
1 answer

Smartgit/hg not listing changed files

I've been trying to use SmartGit/Hg (on Ubuntu Linux, wish SourceTree was available). Just staying in the master because it's only me working and I want to get over this hurdle before I understand branches in SmartGit. I have it on the "main" view,…
Gregory
  • 207
  • 2
  • 12
1
vote
3 answers

Can you stage a file (or at least, a section of a file) DURING a git diff?

Before I stage files, I like to perform a git diff to check that everything is okay. While I'm vertically traversing down a diff, I make a mental note of each file that is "OK" for staging. If it's a particularly long diff, I find it hard to keep…
XåpplI'-I0llwlg'I -
  • 21,649
  • 28
  • 102
  • 151
0
votes
1 answer

Unable to unstage a deleted file with git

After I checked out a branch and did a "git pull" on it, git thinks that I have deleted a file: > git status On branch feature-support Your branch is up to date with 'origin/feature-support'. Changes to be committed: (use "git restore --staged…
pacoverflow
  • 3,726
  • 11
  • 41
  • 71