Git seems to always ignore these.
When I type git add .
, dotfiles in GIT_DIR
are added, but not from subdirectories. On the other hand, git add subdir/.dotfile
won't work.
I tried git add -f
and putting !.*
in GIT_DIR/.git/info/exclude
.
Git seems to always ignore these.
When I type git add .
, dotfiles in GIT_DIR
are added, but not from subdirectories. On the other hand, git add subdir/.dotfile
won't work.
I tried git add -f
and putting !.*
in GIT_DIR/.git/info/exclude
.
git add .
and git add dir/.dot
work fine for me with the unadorned 1.6.6.1 and 1.7.0 versions of Git that I have handy right now.
% git --version
git version 1.6.6.1
% git ls-files -o
.baz/baz
.foo
bar/.bar
quuux/quuux
quux
% git add .
% git ls-files -o
% git ls-files
.baz/baz
.foo
bar/.bar
quuux/quuux
quux
What version of Git are you using? Are your subdirs actually submodules (which are managed independently)?
“dot files” are not excluded by default, but maybe some bit of configuration on your system, repository, or working tree has them set that way. If they show up in git ls-files --exclude-standard -oi
then they are being ignored and "!.*" is the right way to ‘unignore’ them. But to be effective, that pattern has to be in the right place. Ignores are processed in this order:
git config core.excludesfile
(which could be set by
GIT_EDITOR=echo git config --system --edit
to get its pathname)).When a pathname matches a pattern in one file, subsequent files are not consulted. The last match in each file “wins”. A pattern in $GIT_DIR/info/exclude can never override a pattern in a .gitignore file. So, if the files are being ignored (per git ls-files --exclude-standard -oi
) and if "!.*" in $GIT_DIR/info/exclude is ineffective, then check all the applicable .gitignore
files for the culprit.
You can add them specifically by pathname, e.g.,
git add */.*
or
find . -name '.[a-z]*' -exec git add '{}' ';'
(It's good to be careful with the -name
because you don't necessarily want to pick up every directory with its .
entry.)
But by far the easiest way to do this is with git gui
. Just click on the files.
git gitk
–
Ideologist sudo apt-get install gitk
then in a directory with a .git
folder, just type gitk
and you've got "git-gui" for Linux. –
Ideologist git add
for each file takes a really long time. –
Altar If there are only few .dotfiles you need to add, I recommend using -f
flag since simple git add .yourDotFile
does not work on git version 2.28.8 and you do not want to mess with global .gitignore
. Therefore use git add .yourDotFile -f
I just forced it with:
git add . -f
Cheers.
i use
find . -type f | grep -vP '^.\/.git' | xargs git add
the grep -vP '^.\/.git'
exclude everthing wich start with .git
and find get all files include all hidden files.
I dont like the idea of using a 'find' as it might find things you told git to ignore. You could use a bash script. This script will only 'add' a file that is modified, not untracked:
#!/bin/bash
addFile=false
theseLines=($(git status))
for thisLine in "${theseLines[@]}" ; do
if [[ "${addFile}" == 'true' ]] ; then
git add $thisLine
addFile=false
fi
if [[ "${thisLine}" == 'modified:' ]] ; then
addFile=true
#echo 'the next line will be a file that should be added'
fi
done
© 2022 - 2024 — McMap. All rights reserved.