如何從 Git 中的特定修訂版檢索單個檔案? - How to retrieve a single file from a specific revision in Git?
問題:
I have a Git repository and I'd like to see how some files looked a few months ago.我有一個 Git 儲存庫,我想看看幾個月前一些檔案的樣子。 I found the revision at that date;我在那個日期找到了修訂版; it's 27cf8e84bb88e24ae4b4b3df2b77aab91a3735d8
.它是27cf8e84bb88e24ae4b4b3df2b77aab91a3735d8
。 I need to see what one file looks like, and also save it as a ("new") file.我需要檢視一個檔案的外觀,並將其另存為(“新”)檔案。
I managed to see the file using gitk
, but it doesn't have an option to save it.我設法使用gitk
看到了該檔案,但它沒有儲存它的選項。 I tried with command-line tools, the closest I got was:我嘗試使用命令列工具,最接近的是:
git-show 27cf8e84bb88e24ae4b4b3df2b77aab91a3735d8 my_file.txt
However, this command shows a diff, and not the file contents.但是,此命令顯示差異,而不是檔案內容。 I know I can later use something like PAGER=cat
and redirect output to a file, but I don't know how to get to the actual file content.我知道我以後可以使用PAGER=cat
類的東西並將輸出重定向到檔案,但我不知道如何獲取實際的檔案內容。
Basically, I'm looking for something like svn cat .基本上,我正在尋找類似svn cat 的東西。
解決方案:
參考一: https://stackoom.com/question/2Yk4參考二: How to retrieve a single file from a specific revision in Git?
- 如何解決 git 的“不是我們可以合併的東西”錯誤 - How to resolve git's “not something we can merge” error
- 計算一個月的最後一天 - Calculate last day of month
- 我的Objective-C單身人物應該是什麼樣的? [關閉] - What should my Objective-C singleton look like? [closed]
- 為什麼 SQL Server 中的表名以“dbo”開頭? - Why do table names in SQL Server start with “dbo”?
- 從命令列查看錶格檔案,例如 CSV [關閉] - View tabular file such as CSV from command line [closed]
- 在動作建立者中訪問 Redux 狀態? - Accessing Redux state in an action creator?
- 如何將天數新增到今天的日期? [重複] - How to add number of days to today's date? [duplicate]
- 如何刪除 msysgit 的右鍵選單選項? - How do I remove msysgit's right click menu options?
- 如何在 Python 中獲取當前模組中所有類的列表? - How can I get a list of all classes within current module in Python?
- 如何在 iTerm2 中向上滾動更多(增加滾動緩衝區)? - How can I scroll up more (increase the scroll buffer) in iTerm2?
- 如何從命令列執行 TypeScript 檔案? - How to run TypeScript files from command line?
- 使用 LINQ 連線字串 - Using LINQ to concatenate strings
- 如何將NSMutableArray轉換為NSArray? - How do I convert NSMutableArray to NSArray?
- TypeScript 物件作為 C# 中的字典型別 - TypeScript Objects as Dictionary types as in C#
- 如何按值從陣列中刪除一個元素 - How can I delete one element from an array by value
- Angular 2 在 Route Change 上滾動到頂部 - Angular 2 Scroll to top on Route Change
- 如何匯出 MongoDB 中的所有集合? - How to export all collections in MongoDB?
- 什麼是訊號量? - What is a semaphore?
- 如何在我的 Gemfile 中指定本地 gem? - How can I specify a local gem in my Gemfile?
- 為什麼npm install說我有未滿足的依賴關係? - Why does npm install say I have unmet dependencies?