For a project I'm working on, I want to use:
git add . -A
to add some files to the stage. The problem is that Git thinks these files are unchanged from the last commit, so they are ignored. However, I personally changed the file, but Git still sees the file as unchanged.
How can I "forcefully" add that single file to my repository?
The easiest way to add all files to your Git repository is to use the “git add” command followed by the “-A” option for “all”. In this case, the new (or untracked), deleted and modified files will be added to your Git staging area.
When the "assume unchanged" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git.
The git add command can be used to add ignored files with the -f (force) option. Please see git-commit[1] for alternative ways to add content to a commit.
Once you are happy with the staged snapshot that is provided you commit it to the project history with git commit. Remember, git commit is saving changes in Git. You can also use the git reset command to undo a commit or staged snapshot when/if needed.
It seems like the assume-unchanged
-bit is set for that file. With that bit set, git will not look for changes of that file anymore. Unset it by typing:
git update-index --no-assume-unchanged <file>
After that, git status
as well as git add
should detect the changed file.
check your .gitignore file there must be some pattern matching this file which is excluding file from being staged.
Or you can use git add . -f
to forcely add these files.
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