Questions tagged [git-add]

git-add - Add file contents to the index

Before each commit in , you need to add file contents to the staging area.

The following will add all the files currently on the stage at the next commit:

$ git add .

This also adds the files recursively under the current working directory. Files previously tracked (i.e. they were in the last commit), still need to be added to the stage.

You can track new files specifically like so (where foo is the filename in this example):

$ git add foo

To add multiple files, separate them with a space like so (bacon and cheese being the other example files):

$ git add foo bacon cheese

References

330 questions
2
votes
1 answer

'git add .' fails when local repository is in subdirectory of the worktree

I have a problem with git add . failing to add files. I believe (in fact, I'm sure) this is related to the fact that my local repository is located in a subdirectory of the worktree. git add --all works, but I'd like to understand what's going on…
lapk
  • 3,838
  • 1
  • 23
  • 28
2
votes
2 answers

GIT fatal: unable to write new_index file

I interrupted a git add -A command using Ctrl+C and then I run git reset --mixed Now I executed again git add -A and then git commit -m "message" but I get fatal: unable to write new_index file The output of git status: # On branch…
gabboshow
  • 5,359
  • 12
  • 48
  • 98
2
votes
2 answers

Concurrent git checkout/add/commit

I am developing an application which uses Git as a database. My current approach is to call out to the git shell command to construct a new commit whenever the application changes something. This is very simple, but a big disadvantage is that it…
jameshfisher
  • 34,029
  • 31
  • 121
  • 167
2
votes
1 answer

Git: How to "restage" the same lines which were staged?

I have staged some of the modified lines with git add --patch. I have later modified those lines. How could I stage the same lines without selecting them again with git add --patch?
Haralan Dobrev
  • 7,617
  • 2
  • 48
  • 66
2
votes
1 answer

Git add to stage individual lines - like --patch but more precise?

Sometimes the hunks offered to you when you run git add --patch include unrelated changes mixed up with each other because the lines are physically close to each other in the file. Is there a way to interactively add changes to the staging area on a…
Gus Hogg-Blake
  • 2,393
  • 2
  • 21
  • 31
2
votes
2 answers

How could git reset --soft reset last commit without touching index file?

This might be a noob question. Suppose I have a Git repo which already have some files in the staged area by using git add. and then I do a git reset --soft @~ I am happy to see some files I committed last time are put into staged area now. But…
Zhenkai
  • 318
  • 3
  • 15
2
votes
1 answer

How to abort git add -p discarding changes?

I ran git add on some files, constituting a logical separate set of changes, made other changes to them and extracted another logical set of changes using git add -p. Half way through, I realize that I have not committed the previous set, yet. The…
Bengt
  • 14,011
  • 7
  • 48
  • 66
2
votes
3 answers

Adding to git staging means what?

What is the difference between git add and git commit? I understand that former adds to staging. But adding to staging means what? Isn't it an additional step to first add to staging and then do a commit? In fact, it just doesn't end there, we…
Sandbox
  • 7,910
  • 11
  • 53
  • 67
2
votes
1 answer

GIT run script before git add

I often require to do a make clean / make distclean before I do a git add . since I do not want to include binary and other stuffs. I know I can add some name / pattern in to .gitignore but that's not very productive and flexible. Another solution…
w00d
  • 5,416
  • 12
  • 53
  • 85
2
votes
1 answer

Why does git show "dev/null" in status after interactive add of renamed file?

I get an unexpected appearance of "dev/null" in my git status output after interactively adding a patch for a file that was renamed. I'm wondering if this is expected and there is some good reason for this behavior, or if this could be a bug. Below…
Dan Moulding
  • 211,373
  • 23
  • 97
  • 98
2
votes
5 answers

Unable to commit in Git

When I enter in console: $ git add . I get: Nothing added Nothing Specified. May be you wanted to say 'git add.'?
neha
  • 63
  • 3
  • 3
  • 8
2
votes
2 answers

git add -A vs git add file

I got into the habit of using .gitignore and always doing git add -A, git status to check the modified files, then commit, so I don't need to remember about the files that I have modified and other developers don't need to know which files are…
Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307
2
votes
2 answers

Git Not Committing Directory Contents

I'm trying to add every single thing I have in directory through git. However, for one particular directory, it loads the folder, but none of the contents. I tried to use git add -A but was returned # On branch master # Changes not staged for…
user1114864
  • 1,734
  • 6
  • 26
  • 37
2
votes
1 answer

What is the correct 'git-add' command to issue after running 'git-mergetool'?

I'm unclear on the correct sequence of Git commands required to complete a merge that has resulted in conflicts. I understand that one approach is to follow the rejected merge with something like git mergetool # Then once everything has been…
orome
  • 45,163
  • 57
  • 202
  • 418
2
votes
1 answer

How can I commit with cloned submodule in my repo?

I have created a repo for my .vim directory so that I won't need to donfigure that every time I change a machine I am working on. So I have something like that now: user@.vim$ tree -L 3 -a . |-- autoload | `-- pathogen.vim |-- bundle | |--…
Patryk
  • 22,602
  • 44
  • 128
  • 244