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 */

 

解決錯誤error: src refspec master does not match any.error: failed to push some refs to

無法將空文件夾(這里的空文件夾是指不能只有文件夾,需要有一個文件)上傳到github上,需要在文件夾中創建一個文件,這里選擇創建一個README文件

touch README
git add README 
git commit -m 'first commit'
git push origin master

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM