如何选择永远不应该拉到存储库的文件?

时间:2018-09-05 07:57:00

标签: git repository

如何选择永远不应该拉到存储库的文件?

我特别希望此文件myBackend/src/main/resources/application.properties永远不要同步,因为每个用户都将本地设置放在存储在application.properties分支中的模板develop上。

Your branch is up-to-date with 'origin/develop'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   README.md
    modified:   myBackend/docker-compose.yml
    modified:   myBackend/src/main/resources/application.properties

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    myBackend/udo systemctl start docker

no changes added to commit (use "git add" and/or "git commit -a")

此外,我还有一些奇怪的未跟踪文件myBackend/udo systemctl start docker。确实这不是文件。这是错误地写成udo而不是sudo的命令。

如何删除它?

1 个答案:

答案 0 :(得分:2)

要删除本地未跟踪的文件,git clean是您的最佳选择。

首次运行:

git clean -n      //This will display the untracked files that will be removed

然后运行:

git clean -f      //To remove the file(s) - Note: Remove here means Delete

如果是目录,请执行以下操作:

git clean -fd

最后,要忽略文件,只需将其添加到您的.gitignore文件中

所以,就您而言,

Add myBackend/src/main/resources/application.properties to your .gitignore file.