Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

We can use Git's ability to continue tracking files even if they're listed in .gitignore. So, this is enough for .gitignore:

$ cat .gitignore
/*

For each file that you want to track, run add -f (the -f parameter overrides ignoring both in .gitignore and .git/info/exclude):

git add -f .gitignore
git add -f .profile
git add -f .zshrc
git add -f .ssh/config

Once having indexed a file, Git will track all changes despite the fact that the file is ignored. The same works for a directory, but only for the files that are actually present:

git add -f somedirname

If you want to track a whole directory with all new files that appear in it, it can be excluded from .gitignore in a way, described in the answer by camhanswer by camh:

!/somedirname

If you ever want to stop tracking a file, this commands removes a file from Git's index but leaves it untouched on the hard drive:

git rm --cached .ssh/config

We can use Git's ability to continue tracking files even if they're listed in .gitignore. So, this is enough for .gitignore:

$ cat .gitignore
/*

For each file that you want to track, run add -f (the -f parameter overrides ignoring both in .gitignore and .git/info/exclude):

git add -f .gitignore
git add -f .profile
git add -f .zshrc
git add -f .ssh/config

Once having indexed a file, Git will track all changes despite the fact that the file is ignored. The same works for a directory, but only for the files that are actually present:

git add -f somedirname

If you want to track a whole directory with all new files that appear in it, it can be excluded from .gitignore in a way, described in the answer by camh:

!/somedirname

If you ever want to stop tracking a file, this commands removes a file from Git's index but leaves it untouched on the hard drive:

git rm --cached .ssh/config

We can use Git's ability to continue tracking files even if they're listed in .gitignore. So, this is enough for .gitignore:

$ cat .gitignore
/*

For each file that you want to track, run add -f (the -f parameter overrides ignoring both in .gitignore and .git/info/exclude):

git add -f .gitignore
git add -f .profile
git add -f .zshrc
git add -f .ssh/config

Once having indexed a file, Git will track all changes despite the fact that the file is ignored. The same works for a directory, but only for the files that are actually present:

git add -f somedirname

If you want to track a whole directory with all new files that appear in it, it can be excluded from .gitignore in a way, described in the answer by camh:

!/somedirname

If you ever want to stop tracking a file, this commands removes a file from Git's index but leaves it untouched on the hard drive:

git rm --cached .ssh/config
added 273 characters in body
Source Link

There's no need to have a compex .gitignore with multiple exclude-include-reexclude patterns. WeWe can use Git's ability to continue tracking files even if they're listed in .gitignore. So, this is enough for .gitignore:

$ cat .gitignore
/*

For each file that you want to track, run add -f (the -f parameter overrides ignoring both in .gitignore and .git/info/exclude):

git add -f .gitignore
git add -f .profile
git add -f .zshrc
git add -f .ssh/config

Once having indexed a file, Git will track all changes despite the fact that the file is ignored. The same works for a directory, but only for the files that are actually present:

git add -f somedirname

If you want to track a whole directory with all new files that appear in it, it can be excluded from .gitignore in a way, described in the answer by camh:

!/somedirname

If you ever want to stop tracking a file, this commands removes a file from Git's index but leaves it untouched on the hard drive:

git rm --cached .ssh/config

There's no need to have a compex .gitignore with multiple exclude-include-reexclude patterns. We can use Git's ability to continue tracking files even if they're listed in .gitignore. So, this is enough:

$ cat .gitignore
/*

For each file that you want to track, run add -f (the -f parameter overrides ignoring both in .gitignore and .git/info/exclude):

git add -f .gitignore
git add -f .profile
git add -f .zshrc
git add -f .ssh/config

Once having indexed a file, Git will track all changes despite the fact that the file is ignored.

If you ever want to stop tracking a file, this commands removes a file from Git's index but leaves it untouched on the hard drive:

git rm --cached .ssh/config

We can use Git's ability to continue tracking files even if they're listed in .gitignore. So, this is enough for .gitignore:

$ cat .gitignore
/*

For each file that you want to track, run add -f (the -f parameter overrides ignoring both in .gitignore and .git/info/exclude):

git add -f .gitignore
git add -f .profile
git add -f .zshrc
git add -f .ssh/config

Once having indexed a file, Git will track all changes despite the fact that the file is ignored. The same works for a directory, but only for the files that are actually present:

git add -f somedirname

If you want to track a whole directory with all new files that appear in it, it can be excluded from .gitignore in a way, described in the answer by camh:

!/somedirname

If you ever want to stop tracking a file, this commands removes a file from Git's index but leaves it untouched on the hard drive:

git rm --cached .ssh/config
Source Link

There's no need to have a compex .gitignore with multiple exclude-include-reexclude patterns. We can use Git's ability to continue tracking files even if they're listed in .gitignore. So, this is enough:

$ cat .gitignore
/*

For each file that you want to track, run add -f (the -f parameter overrides ignoring both in .gitignore and .git/info/exclude):

git add -f .gitignore
git add -f .profile
git add -f .zshrc
git add -f .ssh/config

Once having indexed a file, Git will track all changes despite the fact that the file is ignored.

If you ever want to stop tracking a file, this commands removes a file from Git's index but leaves it untouched on the hard drive:

git rm --cached .ssh/config