git能在空格和制表符之间自动切换吗?我在python程序中使用选项卡进行缩进,但我希望与使用空格的人协作(使用git)。在推送/取时,GIT是否可以在空格和制表符(例如,4空格=1制表符)之间自动转换?(类似于CR/LF转换)
3 回答
![?](http://img1.sycdn.imooc.com/5458453d0001cd0102200220-100-100.jpg)
月关宝盒
TA贡献1772条经验 获得超5个赞
.git/info/attributes
*.py filter=tabspace
Linux/Unix
git config --global filter.tabspace.smudge 'unexpand --tabs=4 --first-only' git config --global filter.tabspace.clean 'expand --tabs=4 --initial'
OSX
brew install coreutils
git config --global filter.tabspace.smudge 'gunexpand --tabs=4 --first-only' git config --global filter.tabspace.clean 'gexpand --tabs=4 --initial'
所有系统
git checkout HEAD -- **
编辑
![?](http://img1.sycdn.imooc.com/54584eff000195a302200220-100-100.jpg)
慕虎7371278
TA贡献1802条经验 获得超4个赞
每次您签出回购文件时,空格都可以在选项卡中转换, 但是,当您签入(并推送和发布)时,这些相同的文件只使用空格存储。
tabspace
.git/info/attributes
*.py filter=tabspace
# local config for the current repo git config filter.tabspace.smudge 'script_to_make_tabs' git config filter.tabspace.clean 'script_to_make_spaces'
![?](http://img1.sycdn.imooc.com/533e4c9c0001975102200220-100-100.jpg)
POPMUISE
TA贡献1765条经验 获得超5个赞
对于使用GitHub(或其他类似服务)的每个人来说都是非常有用的信息。
~/.gitconfig
[filter "tabspace"] smudge = unexpand --tabs=4 --first-only clean = expand --tabs=4 --initial [filter "tabspace2"] smudge = unexpand --tabs=2 --first-only clean = expand --tabs=2 --initial
attributes
*.js filter=tabspace *.html filter=tabspace *.css filter=tabspace *.json filter=tabspace
attributes2
*.js filter=tabspace2 *.html filter=tabspace2 *.css filter=tabspace2 *.json filter=tabspace2
从事个人项目
mkdir project cd project git init cp ~/path/to/attributes .git/info/
8 space tabs
为其他项目作出贡献
mkdir project cd project git init cp ~/path/to/attributes2 .git/info/attributes git remote add origin git@github.com:some/repo.git git pull origin branch
2 space indented
4 space to 2 space
- 3 回答
- 0 关注
- 1265 浏览
添加回答
举报
0/150
提交
取消