git version 1.7.4.1
I am using git on Ubuntu.
I have copied some files from another directory to my git working directory. Normally would appear under Untracked files
. However, they do not appear. So I cannot add them.
When I do a git status
the new files are not shown.
I tried to add them by doing git add source.c
then tried git status
. The file was not show.
So I opened the file and did a save as
as the same name. git status still failed to see the file.
I have done a git ls-files
and the new files are shown ok.
I have checked the file permissions and they are the same as all the current files in my git directory.
I have never had this problem before.
Many thanks for any suggestions,
Git did not show any new files added to my project. Mine was caused by the following: Somehow my project's main folder got added to the “Repository-specific ignore list” (that's what it's called in SourceTree). This is the “. gitignore” file in the root of my project's main folder.
To add and commit files to a Git repository Create your new files or edit existing files in your local project directory. Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed.
The first approach, using the regular rm command outside of Git, will be viewed by Git as a change to the file. It will show up in the second section of Git status. You'll still need to add the change to the staging area (via git add myfile1. js ) and then commit the change.
If git ls-files
shows source.c
, then it must already be in the index. This means that it is already tracked, and possibly already committed. If source.c
isn't showing up in git status
at all, then the file must have been committed.
Try modifying the file to see if it shows up as modified in git status
. To really convince yourself that the file is checked in, run git cat-file -p HEAD:source.c
to see the contents of the checked-in file (see git help revisions
for documentation about the HEAD:source.c
syntax).
In addition, one or more of the following may be true:
git ls-files -v source.c
. If the first column is a lower-case letter, then the 'assume unchanged' bit is set. This will prevent any changes from showing up in git status
. You can turn off the 'assume unchanged' bit by running git update-index --no-assume-unchanged source.c
.git ls-files -v source.c
is s
or S
then the 'skip-worktree' bit is set. You can turn off the 'skip-worktree' bit by running git update-index --no-skip-worktree source.c
..git/index
(Git will recreate it as necessary).stat()
from working properly. Try running git update-index --really-refresh
. If your working directory is on a network drive (NFS, sshfs, etc.) try moving your repository to a local drive.It's hard to tell what's wrong from the information given, however as a workaround you can try git add -f filename.c
. This will add the file even if it would otherwise be ignored.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With