日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

git 怎么跟踪空目录

發布時間:2024/1/23 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 git 怎么跟踪空目录 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

【問題描述】
git和 svn不同,僅僅跟蹤文件的變動,不跟蹤目錄。所以,一個空目錄,如果里面沒有文件,即便 git add 這個目錄,另外在別處 check out 的時候,是沒有這個空目錄的。

有時候,確實需要在代碼倉庫中保留某個空目錄。比如測試時需要用到的空目錄。下面來看看如何解決:

【解決方案】

Track Empty Directories with git
git 跟蹤空文件夾

There are times when you’d like to track an empty directory within git but there’s a problem: git wont allow you to add a directory that doesn’t have a file in it. The easy solution is putting an empty stub file within the directory, and the industry standard for that stub file name is .gitkeep.

有時您想跟蹤git中的空目錄,但是有一個問題:git不允許您添加其中沒有文件的目錄。 一種簡單的解決方案是在目錄中放入一個空的存根文件,該存根文件名的行業標準是.gitkeep 。

You can quickly create the file and commit the “empty” directory from command line:

您可以快速創建文件并從命令行提交“空”目錄:

touch my-empty-dir/.gitkeep git add my-empty-dir/.gitkeep git commit -m "Adding my empty directory"

注:my-empty-dir是指代空目錄路徑

The problem is simple, the solution is easy, but I wanted to highlight that .gitkeep is the industry standard.

問題很簡單,解決方案很容易,但我想強調.gitkeep是行業標準。

翻譯自:https://davidwalsh.name/git-empty-directory

上述方法注意:不要在項目的.gitignore中設置忽略.gitkeep文件,.gitkeep 是一個約定俗成的文件名并不會帶有特殊規則

總結

以上是生活随笔為你收集整理的git 怎么跟踪空目录的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。