git添加doc文件维护

原文地址:https://www.cnblogs.com/yezuhui/p/6853271.html

说明:

  git 一般只能对纯文本文件进行版本控制,但是如果有其他中间转化软件的协助,就可以对任意二进制文件进行版本控制了。word 的.doc 或者 .docx 就不是一个纯文本文件,所以需要第三方转化工具,将其转化为 纯文本。这里的工具就是 pandoc。pandoc is

步骤:

  1.下载安装工具

    http://pandoc.org/installing.html 

  2.如果是在 unix(linux/macosx)系统下,编辑 ~/.gitconfig 文件,如果是在windows系统下,编辑 git 安装目录下的 /mingw64/etc/gitconfig 文件,加上这么一段话:

[diff "pandoc"]
textconv=pandoc --to=markdown
prompt = false
[alias]
wdiff = diff --word-diff=color --unified=1

  3.然后在你的工程目录下新建一个 .gitattributes(linux/mac)文件(windows是gitattributes 文件),然后写入:

*.docx diff=pandoc
##上面的是docx文件,如果是doc文件,把docx换成doc应该也是一样的。

  4. 在工程目录下初始化git(git init)

  git add . 即把所有的文件都添加进去(包括.gitattributes文件)

  其他的 git commit -m git remote add origin git push origin master 等都是一样的。

猜你喜欢

转载自www.cnblogs.com/of-course/p/11696838.html