如何在Github中保留Makefile的标签 [英] How to preserve tabs in Github for Makefiles
问题描述
Github自动将制表符转换为多个空格.因此,每次我在Github中创建Makefile
时,都需要在Linux框中克隆存储库,并使用vim
编辑Makefile
,然后将push
的更改返回到我的Github存储库,以避免出现以下错误在执行make install|clean
时:
Github automatically converts tabs to multiple spaces. So, every time I create a Makefile
in Github, I need to clone the repository in my Linux box and edit th Makefile
using vim
and then push
the changes back to my Github repository to avoid the following error while executing make install|clean
:
Makefile: : *** missing separator (did you mean TAB instead of 8 spaces?). Stop.
在Github网站中是否存在一种优雅的方式来保存选项卡,尤其是对于Makefiles
?
Is there an elegant way to preserve tabs in Github website especially for Makefiles
?
推荐答案
您可以编写污迹/清除过滤器以在每次提交/检出文件时清除"文件.
该脚本将用所需的格式替换所有空格/制表符.
You can write a smudge/clean filters to "clean" up the file every commit/checkout of files.
The script will replace any spaces/tabs with the desired format.
smudge/clean是过滤器,只要您将文件(clean)和检出文件提交到工作目录(smudge),它们就会运行.
The smudge/clean are filters which are runs whenever you commit file (clean) and checkout file to a working directory (smudge).
在此阅读所有内容并在此处进行设置:
https://git-scm.com/book/zh/v2/Customizing-Git-Git-Attributes
Read all about it and to set it up here:
https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes
事实证明,您可以编写自己的过滤器,以便在提交/签出上的文件中进行替换.
It turns out that you can write your own filters for doing substitutions in files on commit/checkout.
这些被称为clean
和smudge
过滤器.
These are called clean
and smudge
filters.
在.gitattributes
文件中,可以为特定路径设置过滤器,然后设置脚本以在检出文件(涂抹")之前和在暂存文件(清理")之前处理文件. ).
In the .gitattributes
file, you can set a filter for particular paths and then set up scripts that will process files just before they’re checked out ("smudge") and just before they’re staged ("clean").
可以将这些过滤器设置为执行各种有趣的事情.
These filters can be set to do all sorts of fun things.
这篇关于如何在Github中保留Makefile的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!