GitHub使用整理——关于上传Keil工程一些注意的点

git上传警告warning: LF will be replaced by CRLF

在上传keil工程时,会遇到warning: LF will be replaced by CRLF警告;

warning: LF will be replaced by CRLF in <file-name>.
The file will have its original line endings in your working directory.

同时下面这句话很重要,即“在工作区里,这个文件会保持它原本的换行符。”

如何理解LF和CRLF:

1.LF和CRLF都是换行符,在各操作系统下,换行符是不一样的,Linux/UNIX下是LF,而Windows下是CRLF,早期的MAC OS是CR,后来的OS X在更换内核后和UNIX一样也是LF.
这种不统一确实对跨平台的文件交换带来了麻烦。虽然靠谱的文本编辑器和 IDE 都支持这几种换行符,但文件在保存时总要有一个固定的标准啊,比如跨平台协作的项目源码,到底保存为哪种风格的换行符呢?

2.Git 由大名鼎鼎的 Linus 开发,最初只可运行于 *nix 系统,因此推荐只将 UNIX 风格的换行符保存入库。但它也考虑到了跨平台协作的场景,并且提供了一个“换行符自动转换”功能。

    • 安装好 GitHub 的 Windows 客户端之后,这个功能默认处于“自动模式”。
    • 当你在签出文件时,Git 试图将 UNIX 换行符(LF)替换为 Windows 的换行符(CRLF);当你在提交文件时,它又试图将 CRLF 替换为 LF。
      所以Git在拉取代码的时候,git会自动将代码之中与你当前系统不同的换行方式自动转换成当前系统的换行方式。
      这样一来在提交代码的时候,git会认为你未修改内容的文件也认为是修改过的,然后提示你warning: LF will be replaced by CRLF这样的信息。

有效的解决方法

如果设置core.autocrlf = false,那么很可能会出现CRLF和LF混合的情况,这样会导致一些问题,例如git diff 失去功能,会发现很多行代码并没有修改,然而被认为是修改过了。
首先core.autocrlf = true在windows上才是正确的选择,那么如何避免warning呢?还要有以下几个步骤:

    • 添加.gitattributes
    • 设置core.safecrlf = true
    • 使用dos2unix、notepad++等工具来将LF转换成CRLF

以上资料转载自:

https://www.cnblogs.com/sminocence/p/9357209.html

关于git存储空间的注意:

Git本身没有设置用户的磁盘额度,但是建议每个项目的大小保持在1G左右,当你超过75G时会产生警告,且存储库的硬限制为100GB,另外,git严格限制超过100 MB的文件;

Git没有充分设计用作备份工具。但是,有许多专门用于执行值得检查的备份的解决方案,包括ArqCarboniteMozyCrashPlan

导致Git存储库变得庞大和膨胀的另一件事是外部依赖,最好将这些文件保留在存储库之外,而是使用包管理器,大多数流行语言都附带包管理器,可以为您执行此操作。BundlerNode的软件包管理器Maven它们每个都支持直接使用Git存储库,因此您不需要预先打包的源;

Git不建议在您的存储库中分发已编译的代码和预打包的版本;

以上资料来自:

https://help.github.com/en/articles/what-is-my-disk-quota

关于Keil工程的精简:

首先清除掉keil工程的编译文件,可以通过以下的批处理实现:

::删除Keil编译产生的一些垃圾文件
::删除Code Warrior编译产生的一些垃圾文件
del *.bak /s
del *.ddk /s
del *.edk /s
del *.lst /s
del *.lnp /s
del *.mpf /s
del *.mpj /s
del *.obj /s
del *.omf /s
::del *.opt /s  ::不允许删除JTAG的设置
del *.plg /s
del *.rpt /s
del *.tmp /s
del *.__i /s
del *.crf /s
del *.o /s
del *.d /s
del *.axf /s
del *.tra /s
del *.dep /s           
del JLinkLog.txt /s
del *.iex /s
del *.htm /s
del *.sct /s
del *.map /s
del *._2i /s
del *.L2P /s
del *.FED /s

del *.elf /s
del *.args /s
del *.mk /s
del *.local /s

exit

将以上的代码新建txt文件,拷贝进去后将文件名改为name.bat放入到keil工程中;

关于STM32-F4外设库的精简:

基于原子哥的工程模板,对采用外设库的F4工程进行精简;

删除外设库文件,保留下基本的外设库文件只有以下几个:

misc.c
misc.h    //NVIC配置

stm32f4xx_rcc.c
stm32f4xx_rcc.h    //时钟配置

stm32f4xx_gpio.c
stm32f4xx_gpio.h    
stm32f4xx_usart.c
stm32f4xx_usart.h    //串口配置要用

同时修改stm32f4xx_conf.h文件中的外设包含关系:

/* Includes ------------------------------------------------------------------*/
/* Uncomment the line below to enable peripheral header file inclusion */
//#include "stm32f4xx_adc.h"
//#include "stm32f4xx_crc.h"
//#include "stm32f4xx_dbgmcu.h"
//#include "stm32f4xx_dma.h"
//#include "stm32f4xx_exti.h"
//#include "stm32f4xx_flash.h"
#include "stm32f4xx_gpio.h"
//#include "stm32f4xx_i2c.h"
//#include "stm32f4xx_iwdg.h"
//#include "stm32f4xx_pwr.h"
#include "stm32f4xx_rcc.h"
//#include "stm32f4xx_rtc.h"
//#include "stm32f4xx_sdio.h"
//#include "stm32f4xx_spi.h"
//#include "stm32f4xx_syscfg.h"
//#include "stm32f4xx_tim.h"
#include "stm32f4xx_usart.h"
//#include "stm32f4xx_wwdg.h"
#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
#if defined(STM32F40_41xxx)
//#include "stm32f4xx_cryp.h"
//#include "stm32f4xx_hash.h"
//#include "stm32f4xx_rng.h"
//#include "stm32f4xx_can.h"
//#include "stm32f4xx_dac.h"
//#include "stm32f4xx_dcmi.h"
//#include "stm32f4xx_fsmc.h"
#endif /* STM32F40_41xxx */

猜你喜欢

转载自www.cnblogs.com/lpfdezh/p/11050451.html