如何选择永远不会被拉到存储库的文件? [重复]

问题描述 投票:0回答:1

这个问题在这里已有答案:

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

特别是我希望这个文件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写的命令。

我该如何删除它?

git repository
1个回答
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.
© www.soinside.com 2019 - 2024. All rights reserved.