GIT - 稀疏结帐不按预期工作 [英] GIT - sparse checkout not working as expected
问题描述
我在服务器上签出了一个git repo。
回购用于在根上拥有所有相关文件,但我必须进行一些更改,现在我有两个文件夹, src
和 dist
并且我想跟踪两者。
我得到的问题是在我的服务器上,如果我拉,我现在必须在dist文件夹内导航以查看内容。
我尝试搜索一下,我认为我想要做的就是称为稀疏结帐。
我遵循本教程:
另一种解决方案也可能适用于您:
I've a git repo checked out on a server.
The repo used to have all the relevant files on the root, but i had to make some changes and now i have two folders, The problem i've got is that on my server, if i pull, i now have to navigate inside dist folder in order to see something. I tried to search a bit and i think that what i'd like to do is called sparse-checkout. I followed this tutorial: http://jasonkarns.com/blog/subdirectory-checkouts-with-git-sparse-checkout/, in particular the part that talks about an existing project and i did what mentioned: but nothing happend. I mean, i still need to navigate to myproject/dist to being able to see something. I also tried to Am i missing something here? You did everything as it should be. With sparse checkout you basically tell Git to exclude a certain set of files from the working tree.
Those files will still be part of the repository but they won't show up in your working directory. Internally, sparse checkout uses the 将子文件夹拆分为新的分支/存储库
$ b $ pre $ #使用filter-branch将所需的文件夹提取到新的文件夹中分支
#完成工作后,您可以再次合并它。
git filter-branch --prune-empty --subdirectory-filter YOUR_FOLDER_NAME< branch>
#将主分支过滤到您的目录并删除空提交
src
and dist
and i want to track both.
cat sparse-checkout
file and dist/
is present.
I tried git pull origin master
as well, but with no luck.
sparse checkout
skip-worktree
flag to mark all the excluded files as always updated.
# 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
Another solution which might work for you as well:
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
这篇关于GIT - 稀疏结帐不按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!