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
4
votes
2 answers

Why cannot add a large file to a Git repository

Why Git does not support committing very big files? I'm trying to add a 4Gb file and I get the following error: C:\Users\danipen\gitrepos\vmstore>git add mybigfile.rar fatal: Out of memory? mmap failed: No such file or directory UPDATE: Seems that…
Daniel Peñalba
  • 30,507
  • 32
  • 137
  • 219
4
votes
2 answers

Why do I need to do a 'git add ' after resolving merge conflicts?

I've come here even after looking at this link - How to resolve merge conflicts in Git? and many other links. Everywhere, it is mentioned that you need to do a 'git add' after resolving the conflicts in a text editor. I've been using git for a few…
Devesh
  • 859
  • 8
  • 17
4
votes
1 answer

GIT - git-add error (Bad File Number)

I'm using Git to create a backup system. I've just created the directory and initialized git on it. git init When I tried to add the untracked files to the stage with git add -u *.pdf I get this response error: sh.exe": /bin/git: Bad file…
luisfsns
  • 81
  • 1
  • 6
4
votes
4 answers

How to add multiple files in git

I have 4 files in a folder. I have modified 3 of them. How do I add and push only the modified files all at once. Will "git add ." work here.
Stacy J
  • 2,721
  • 15
  • 58
  • 92
3
votes
3 answers

What's the difference between Git add (ctrl+A) and Stage to Commit (ctrl+T) in the git GUI?

If git add CTRL+A starts tracking changes AND stages changes to already tracked files, why should I ever use Stage to Commit CTRL+T in the git gui ?
Nike
  • 1,223
  • 2
  • 19
  • 42
3
votes
1 answer

`Git add --patch` multiple files: go to hunk from previous file

When running git add --patch, it presents a series of "hunks" that can be applied or skipped with y or n respectively, along with other options for editing/etc. On occasion, when working with a lot of files, I have unintentionally marked n to the…
Human-Compiler
  • 11,022
  • 1
  • 32
  • 59
3
votes
1 answer

unable to add files with git add

I have tried to git add a file. But when I check git status, the file is still marked as "Changes not staged for commit". I have read many similar questions and I have tried everything: make sure I am in the right repository make sure there is no…
Andre
  • 321
  • 1
  • 12
3
votes
2 answers

WSL+samba+git: "error: insufficient permission for adding an object to repository database .git/objects" / git-clone / git-add permission errors

I'm working on Win10 using the WSL1 (Windows Linux Subsystem) with Ubuntu 20.04.1 LTS. I have a Samba (1.0) Network Share on which I want to create my git repository via my Ubuntu Terminal. christian@my_pc:~/p/git_test$ ll total 2048 drwxr-xr-x 1…
chris h.
  • 265
  • 1
  • 4
  • 18
3
votes
2 answers

Git merge file content outside of a repo (--no-index)

The git diff command (with the --no-index flag) works incredibly well to diff two files, irrespective of whether or not these two files are contained in a Git repo or not. Example $ git diff --no-index -- filea fileb // shows diff between filea and…
friederbluemle
  • 33,549
  • 14
  • 108
  • 109
3
votes
1 answer

Can I make "git add -p" to immediately quit after added hunk?

With git add -p I can add individual hunks step by step. In many cases I want to add exactly one hunk and then quit the interactive mode immediately. I don't want the next hunk to show up, because it will confuse me when writing the commit message,…
donquixote
  • 4,877
  • 3
  • 31
  • 54
3
votes
1 answer

Git add files which do not match a pattern

In Git, while adding files to a commit, we can add all files matching a pattern like so: git add **Component** I find this feature pretty useful to quickly add lots of files with similar names. For example, If all my files are named based on…
Sumit
  • 2,189
  • 7
  • 32
  • 50
3
votes
1 answer

What does git add -n --ignore-missing actually do?

This seems simple enough, but I'm having a difficult time understanding the difference between the following commands: git add -n and git add -n --ignore-missing I believe I understand what "git add -n" does in the sense that it is a dry run of…
user6312047
3
votes
1 answer

.gitignore, git add, and files mysteriously disappearing

I have a project, and have shared the root folder through git. My compatriots and I are using different versions of Gradle (and have named the project different things), so it would be appropriate for some things in the .idea folder (a certain…
FWhitaker
  • 31
  • 1
3
votes
1 answer

Is it possible to use the “minimal” algorithm for interactive adding?

Git doesn't always choose hunk boundaries correctly, when calculating a changeset from snapshots. git diff has a --diff-algorithm option that allows some tweaking in this regard; git diff --minimal sometimes gives better results than git diff…
leftaroundabout
  • 117,950
  • 5
  • 174
  • 319
3
votes
1 answer

git remove a file that no longer exists on the system

I have never encountered this problem before and have no idea how this is possible. I had a really large directory that I downloaded by mistake into my git repo. I inadvertently did a git add . so the large directory got added to the working tree…
anonuser0428
  • 11,789
  • 22
  • 63
  • 86