簡體   English   中英

GIT - 稀疏結帳未按預期工作

[英]GIT - sparse checkout not working as expected

我在服務器上檢出了一個 git repo。 該 repo 曾經在根目錄上包含所有相關文件,但我必須進行一些更改,現在我有兩個文件夾, srcdist ,我想跟蹤這兩個文件夾。

我遇到的問題是,在我的服務器上,如果我拉,我現在必須在 dist 文件夾中導航才能看到一些東西。

我試着搜索了一下,我認為我想做的是所謂的稀疏結帳。

我遵循了本教程: http : //jasonkarns.com/blog/subdirectory-checkouts-with-git-sparse-checkout/ ,特別是談論現有項目的部分,我做了提到的事情:

  1. ssh 進入我的服務器
  2. cd 進入項目文件夾
  3. git config core.sparsecheckout 真
  4. echo dist/ >> .git/info/sparse-checkout
  5. git read-tree -mu HEAD

但什么也沒發生。 我的意思是,我仍然需要導航到 myproject/dist 才能看到一些東西。

我還嘗試cat sparse-checkout文件並且dist/存在。 我也試過git pull origin master ,但沒有運氣。

我在這里錯過了什么嗎?

你做了所有應該做的事情。


sparse checkout

通過稀疏結帳,您基本上可以告訴 Git 從工作樹中排除某些文件集。 這些文件仍將是存儲庫的一部分,但它們不會出現在您的工作目錄中。

在內部,稀疏檢出使用skip-worktree標志將所有排除的文件標記為始終更新。

 # enable sparse checkout in an existing repository: git config core.sparseCheckout true # Create a .git/info/sparse-checkout file containing the # paths to include/exclude from your working directory. # Update your working directory with git read-tree -mu HEAD

在此處輸入圖片說明


另一種可能對您有用的解決方案:

Splitting a subfolder out into a new branch/repository

# use filter-branch to extract only the desired folder into a new branch
# once you done with your work you can always merge it back again.

git filter-branch --prune-empty --subdirectory-filter YOUR_FOLDER_NAME <branch>
# Filter the master branch to your directory and remove empty commits

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM