自定义git

一、配置git
1、/etc/gitconfig-----git config  --system
2、~/.gitconfig-------git config  --global
3、project/.git/config
4、git  config --help--查看选项
5、客户端常用配置选项
  1)it config --global core.editor emacs
  2)git config --global commit.template $HOME/.gitmessage.txt
  3)git config --global core.pager ''--取消默认分页,只显示一页
  4)git config --global user.signingkey <gpg-key-id>
     git tag -s <tag-name>
  5)core.excludesfile--排除文件,同.gitignore
  6) git config --global color.ui true
  7) git config --global core.autocrlf true
  8) 修正空白
    git config --global core.whitespace
    trailing-space,space-before-tab,indent-with-non-tab
     ---通过逗号分割的链中去掉选项或在选项前加 - 来关闭
    A、默认被打开的2个选项是 trailing-space 和 space-before-tab ,
     trailing-space 会查找每行结尾的空格, space-before-tab 会查找每行开头的制表符前的空格。
    B、默认被关闭的2个选项是 indent-with-non-tab 和 cr-at-eol ,
     indent-with-non-tab 会查找8个以上空格(非制表符)开头的行,
     cr-at-eol 让 Git 知道行尾回车符是合法的。
6、服务端常用配置选项
  1)git config --system receive.fsckObjects true --推送时开启一致性检查
  2)git config --system receive.denyNonFastForwards true--禁用强制更新
      -在push命令后加 -f 标志来强制更新
  3)git config --system receive.denyDeletes true
      --会在推送过程中阻止删除分支和标签
二、配置属性
1、属性文件是:项目目录下.gitattributes 文件内进行设置
   也可以在 .git/info/attributes 进行设置
2、对特定目录和子文件集进行特定的动作
 1)把文本文件识别为二进制文件
   让 Git 把所有 pbxproj 文件当成二进制文件,在 .gitattributes 文件中设置如下
   *.pbxproj binary===*.pbxproj -crlf -diff
 2)word二进制文件的比较
   A、先配置转换过滤器strings,把word转换为文本
      git config diff.word.textconv strings
   B、在属性文件中设置diff操作利用word过滤器
     *.doc diff=word
 3)图片比较,安装exiftool
   $ echo '*.png diff=exif' >> .gitattributes
   $ git config diff.exif.textconv exiftool
三、配置过滤器例子
  1、在属性文件中指定针对特定的目录和记录集应用过滤器
    echo 'date*.txt filter=dater' >> .gitattributes
    ---对date*.txt文件,应用过滤器dater
  2、过滤器dater定义
    A、定义expand_date脚本
    B、git config filter.dater.smudge expand_date
       --本质上修改文件~/.gitconfig
    【filter】
       dater.smudge=expand_date
    C、触发过滤器事件
      ---smudge,签出前触发,修改特定文件集合
      ---clean,提交到暂存前触发,修改特定文件集合
  3、脚本实例
    #! /usr/bin/env ruby
    data = STDIN.read------从标准输入里面读取
    last_date = `git log --pretty=format:"%ad" -1`
    puts data.gsub('$Date$', '$Date: ' + last_date.to_s + '$')
  4、思路,就是在源文件中添加占位符号$mark$,然后在过滤脚本对$mark$进行处理
四、导出仓库归档
  1、test/ export-ignore 忽略导出
  2、导出替换export-subst
  $ echo 'Last commit date: $Format:%cd$' > LAST_COMMIT
  $ echo "LAST_COMMIT export-subst" >> .gitattributes
  $ git add LAST_COMMIT .gitattributes
  $ git commit -am 'adding LAST_COMMIT file for archives'
  ---git archive
  ---查看 LAST_COMMIT文件
五、合并策略 ???
 database.xml merge=ours

转载于:https://www.cnblogs.com/justart/p/11519953.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值