简体   繁体   English

Git:将一些文件/目录保持在本地,而不是推送到远程

[英]Git : keeping some files/directories local and not pushed to remote

I'd like to keep some private information (files/folders) on the local git directories (say server info etc) but everything else pushed to a public server say GitHub.我想在本地 git 目录(比如服务器信息等)上保留一些私人信息(文件/文件夹),但其他所有信息都推送到公共服务器上,比如 GitHub。

Of course I'd backup all the files locally as well.当然,我也会在本地备份所有文件。

What is the proper way of achieving my aim.实现我的目标的正确方法是什么。 .gitignore? .gitignore?

I think modifying .gitignore in your case would be a helpful and easy way to ignore files and folders.我认为在您的情况下修改.gitignore将是一种忽略文件和文件夹的有用且简单的方法。 We also do store all our server info locally in properties files and ignore them.我们还将所有服务器信息本地存储在属性文件中并忽略它们。

Eg :

filename.properties
*.properties
folder-path/

Additionally you can check this answer as well .gitignore exclude folder but include specific subfolder此外,您也可以检查此答案.gitignore exclude folder 但包括特定的子文件夹

You will be having a file named ".gitignore" in your project path.您的项目路径中将有一个名为“.gitignore”的文件。 open that in a text editor and whether the path is mentioned in the git ignore file.在文本编辑器中打开它,并在 git 忽略文件中提到该路径。 If so, just remove that from the file and save it then you should be able to commit and push如果是这样,只需从文件中删除并保存它,那么您应该能够提交和推送

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM