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
1
vote
2 answers

Broke my local git repo

For whatever reason my .gitignore is failing to ignore my node_modules directory. When I do a git status it's returning a bunch of deleted and modified files that are under a directory it's supposed to ignore, and it's not picking up files I've…
gh0st
  • 1,653
  • 3
  • 27
  • 59
1
vote
2 answers

Git add new files but do not resolve conflicts

I'm looking for a way I can automatically add all new files, but not mark conflicts as resolved. I have set up some ant scripts to do basic Git functions to help non-developers handle routine operations. Been doing this for a while and decided that…
kencorbin
  • 1,958
  • 1
  • 20
  • 18
1
vote
1 answer

Why won't Git include this file?

I am trying the following commit (in Posh-Git on PowerShell): C:\Dev\Android\Projects\HeavyWeights [master ≡ +0 ~1 -0 !]> git commit -a On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: modified:…
ProfK
  • 49,207
  • 121
  • 399
  • 775
1
vote
2 answers

Why is vendor package not pushing to github even when "/vendor" is not listed in .gitignore file?

When I add files to my local repository, some vendor packages are excluded even though they are not listed in the .gitignore file. Since they are not pushed to the remote repository, other developers are not able to pull the vendor packages.
1
vote
1 answer

Which plumbing commands achieve the same as git add?

I'd like to understand git-plumbing better by learning what actually happens when entering git add $DIRECTORY and git add $FILE How does it work? A rough idea can be gained by reading the progit's git internals section. If $DIRECTORY is a…
Tobias Kienzler
  • 25,759
  • 22
  • 127
  • 221
1
vote
3 answers

files in the git repo are both deleted and untracked but they're still there. How is that possible?

All the (hundreds of) files in my repo now show up as untracked and deleted though I can't figure out what's going on? ls shows the files are in the directory but git status . in the directory has the files as deleted and untracked. I haven't…
Evan Hobbs
  • 3,552
  • 5
  • 30
  • 42
1
vote
1 answer

How automatically add to version control new content in a new directory?

I created a new fonts directory under app/assets/ and added to version control the fonts directory with git add fonts. Usually, when I create or include a new file in any place of my project folder already under version control, this new file is…
Asarluhi
  • 1,280
  • 3
  • 22
  • 43
1
vote
1 answer

How can I see the original form of an edited hunk?

git add -p is handy to stage only parts of the uncommitted work. Usually, it's just a matter of confirming/denying whether some individual hunks should go in the commit. However, sometimes I need to split up a hunk finer than the s option will go.…
leftaroundabout
  • 117,950
  • 5
  • 174
  • 319
1
vote
2 answers

Revert version of file in git staging area

New newbie here. This is related to manipulating staging area of git. Say I have a file named cat.txt. It's git committed version has a single line in it. Then I edited cat.txt added a second line and staged it. Then edited again, added third line…
BBDG
  • 365
  • 4
  • 11
1
vote
2 answers

How to git ignore everything but one folder?

I have a git repo in my home folder. I'm trying to NOT include basically the entirety of my home folder, with the exception of my .vim folder. In my .gitignore, I have * !.vim The problem is that this only adds the .vim directory into my git repo,…
George
  • 6,927
  • 4
  • 34
  • 67
1
vote
1 answer

Can we restore the files that were removed by a reset if they are staged?

In general, we can restore all the objects that are stored as commits even if they are reset by using reflog. As I understand it, this is because they work with the git objects present in the .git directory. So, is it possible to restore files if…
Naveen Dennis
  • 1,223
  • 3
  • 24
  • 39
1
vote
1 answer

Missing files in git index

I work on a git repo with many many branches in it. Now i wanted to add a new feature from another location. So i did cp -r /source /target The new files are in my repo, but git ignores them. If i do git status after i copied that files, git says…
Maik Hagenbruch
  • 83
  • 1
  • 13
1
vote
0 answers

Is there an option for "git add -?" to add only newly added files / removed files

git status gives me: a list of added files a list of modified files a list of removed files What I know: git add -A --> all 3 lists git add . ---> all 3 lists git add --ignore-removal . ---> new and mod only git add -u --> mod and…
hello_harry
  • 1,265
  • 2
  • 14
  • 24
1
vote
0 answers

How do I avoid the `update-index` operation during a `git add -i`?

I have a considerably large Git repository. As such, I try very hard to avoid running any Git operations which are slow. For example, my status command is always something like git status -uno -- which completes nicely within a second (versus…
Alexander
  • 415
  • 3
  • 10
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