Ignore the file from git commit, but protect it from being clean

In my work tree, I have a mix of files in .gitignore:

  • Output assembly
  • Sensitive files that should not be part of the repo (for example, passwords, connection information for local servers)

If I want to rebuild the project from scratch, I can do git clean -xto remove the build outputs in (1). But it also removes sensitive files in (2).

Is there a way to mark a file so that it is not affected git clean, but is still ignored git commit?

+6
source share
3 answers

The documentation for git-cleansays that -x:

-x

, .gitignore ( ) $GIT_DIR/info/exclude, , -e.

, , , keys.pem,

git clean -fdxe keys.pem

alias .

+3

git clean :

:

, , " โ†’ ". .. "*.c *.h" , ".c" ".h" . , ENTER () .

0

@Borealid Git - "- " "skip-worktree" .

, skip-worktree - . , , , . , skip-worktree, , , .

skip-worktree, , , .gitignore git clean. , - exclude git clean, .

  • / , . , myusername. .
  • git clean -dx --exclude=myusername.* ( ).
  • script, , myusername., myusername..

, , / , , , , script. , readonly. , script.

skip-worktree.

0
source

Source: https://habr.com/ru/post/1016858/


All Articles