Git-在推/拉时忽略但不克隆 [英] Git - ignore on push/pull but not clone

查看:99
本文介绍了Git-在推/拉时忽略但不克隆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何方法可以忽略文件的推/拉操作,而是将其复制到克隆文件上?在这种情况下,我需要一个配置文件.当我克隆仓库时,我想拉入默认配置,但是对于所有其他操作,请忽略更改.因此,在克隆reop时会包含默认配置文件,但之后对其所做的任何更改都将被忽略.

Is there any way to ignore a file for push/pull but copy it on clone? In this case I want a config file. When I clone the repo I'd like to pull in the default config but for all other operations ignore the changes. So when cloning the reop the default config file is included, but then any changes to it afterwards are ignored.

不提交文件的问题是,由于文件已更改,在尝试从主服务器进行拉取时会引起问题.

The problem with just not committing the file is that it causes issues when trying to do a pull from master as the file has changed.

我可以添加.gitignore文件,但这意味着克隆存储库后必须手动创建它.

I can add the file .gitignore but this means I have to manually create it after cloning the repo.

推荐答案

否.忽略的文件不在git存储库中,因此无法克隆.只需创建config.example文件,然后在克隆后将其复制到config.

No. Ignored file is not in git repository, so it cannot be cloned. Just create config.example file and copy it to config after cloning.

这篇关于Git-在推/拉时忽略但不克隆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆