第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

git-diff忽略^ M

git-diff忽略^ M

Git
皈依舞 2019-09-27 16:31:53
在某些文件包含^ M作為換行符的項(xiàng)目中。顯然不可能對(duì)這些文件進(jìn)行區(qū)分,因?yàn)間it-diff將其視為整個(gè)文件僅一行。與以前的版本有何不同?是否有類似“比較時(shí)將^ M作為換行符”的選項(xiàng)?prompt> git-diff "HEAD^" -- MyFile.as diff --git a/myproject/MyFile.as b/myproject/MyFile.asindex be78321..a393ba3 100644--- a/myproject/MyFile.cpp+++ b/myproject/MyFile.cpp@@ -1 +1 @@-<U+FEFF>import flash.events.MouseEvent;^Mimport mx.controls.*;^Mimport mx.utils.Delegate\ No newline at end of file+<U+FEFF>import flash.events.MouseEvent;^Mimport mx.controls.*;^Mimport mx.utils.Delegate\ No newline at end of fileprompt>更新:現(xiàn)在,我編寫了一個(gè)腳本,用于檢查最新的10個(gè)修訂并將CR轉(zhuǎn)換為LF。require 'fileutils'if ARGV.size != 3  puts "a git-path must be provided"  puts "a filename must be provided"  puts "a result-dir must be provided"  puts "example:"  puts "ruby gitcrdiff.rb project/dir1/dir2/dir3/ SomeFile.cpp tmp_somefile"  exit(1)endgitpath = ARGV[0]filename = ARGV[1]resultdir = ARGV[2]unless FileTest.exist?(".git")  puts "this command must be run in the same dir as where .git resides"  exit(1)endif FileTest.exist?(resultdir)  puts "the result dir must not exist"  exit(1)endFileUtils.mkdir(resultdir)10.times do |i|  revision = "^" * i  cmd = "git show HEAD#{revision}:#{gitpath}#{filename} | tr '\\r' '\\n' > #{resultdir}/#{filename}_rev#{i}"  puts cmd   system cmdend
查看完整描述

3 回答

?
慕娘9325324

TA貢獻(xiàn)1783條經(jīng)驗(yàn) 獲得超4個(gè)贊

GitHub建議您確保在git處理的存儲(chǔ)庫中僅使用\ n作為換行符。有一個(gè)自動(dòng)轉(zhuǎn)換選項(xiàng):


$ git config --global core.autocrlf true

當(dāng)然,據(jù)說這是將crlf轉(zhuǎn)換為lf,而您想將crlf轉(zhuǎn)換為lf。我希望這仍然有效...


然后轉(zhuǎn)換文件:


# Remove everything from the index

$ git rm --cached -r .


# Re-add all the deleted files to the index

# You should get lots of messages like: "warning: CRLF will be replaced by LF in <file>."

$ git diff --cached --name-only -z | xargs -0 git add


# Commit

$ git commit -m "Fix CRLF"

手冊(cè)頁中介紹了 core.autocrlf 。


查看完整回答
反對(duì) 回復(fù) 2019-09-27
?
江戶川亂折騰

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超5個(gè)贊

在Windows上進(jìn)行開發(fā)時(shí),使用時(shí)遇到了這個(gè)問題git tfs。我是這樣解決的:

git config --global core.whitespace cr-at-eol

這基本上告訴Git行尾CR并不是錯(cuò)誤。其結(jié)果是,那些煩人的^M字符不再出現(xiàn)在線路末端git diff,git show等等。

似乎保留了其他設(shè)置。例如,行尾的多余空格仍會(huì)在差異中顯示為錯(cuò)誤(以紅色突出顯示)。

(其他答案都暗示了這一點(diǎn),但是以上正是設(shè)置設(shè)置的方法。要僅為一個(gè)項(xiàng)目設(shè)置設(shè)置,請(qǐng)省略--global。)

編輯

在經(jīng)歷了許多行尾麻煩之后,在.NET團(tuán)隊(duì)中工作時(shí),我有以下設(shè)置是最幸運(yùn)的:

  • 沒有core.eol設(shè)置

  • 沒有core.whitespace設(shè)置

  • 沒有core.autocrlf設(shè)置

  • 當(dāng)運(yùn)行Windows的Git安裝程序時(shí),您將獲得以下三個(gè)選項(xiàng):

    • 簽出Windows風(fēng)格,提交Unix風(fēng)格的行結(jié)尾 <-選擇這一行

    • 按原樣簽出,提交Unix樣式的行尾

    • 按原樣簽出,按原樣提交

如果需要使用空格設(shè)置,則可能需要在與TFS進(jìn)行交互時(shí)僅在每個(gè)項(xiàng)目中啟用它。只需省略--global

git config core.whitespace cr-at-eol

如果您需要?jiǎng)h除一些core。*設(shè)置,最簡單的方法是運(yùn)行以下命令:

git config --global -e

這將在文本編輯器中打開全局.gitconfig文件,您可以輕松刪除要?jiǎng)h除的行。(或者,您也可以在它們前面加上“?!币詫⑵渥⑨尩?。)


查看完整回答
反對(duì) 回復(fù) 2019-09-27
?
DIEA

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超3個(gè)贊

另請(qǐng)參閱:


core.whitespace = cr-at-eol

或等效地,


[core]

    whitespace = cr-at-eol

其中whitespace以制表符開頭。


查看完整回答
反對(duì) 回復(fù) 2019-09-27
  • 3 回答
  • 0 關(guān)注
  • 1973 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)