Git Stash& Worktree Woes [英] Git Stash & Worktree Woes
问题描述
$ b $我有一个helluva时间让git与我的用户定义的worktree合作,该工作树存在 outside 包含我的.git目录的文件夹。基本上这个设置是这样的:我有两个目录,一个叫做git-worktree,它包含我想要跟踪的文件,另一个名为git-dir,其中包含存储库的.git文件夹,即GIT_DIR。
我通过cd'ing入文件夹git-dir来运行: b
$ b
git --git-dir =。/。git --work-tree = / Users / braitsch / Test / git-worktree / init
这成功初始化了存储库,而当我处于git-dir文件夹时,我可以添加工作树中的文件,运行git status并提交他们。很酷。
当我尝试运行git存储时,这里出现了这个问题:
致命:/ usr / local / git / libexec / git-core / git-stash不能在没有工作树的情况下使用。
现在这是BS,因为我知道(或者至少我认为)我有工作树集到包含我要跟踪的文件的git-worktree文件夹。
git config --local -l向我显示以下内容:
core.repositoryformatversion = 0
core.filemode = true
core.bare = false
core.logallrefupdates = true
core.worktree = / Users / braitsch / Test / git-worktree
core.ignorecase = true
我甚至尝试手动将.git文件夹添加到本地配置文件,以查看是否有帮助,但无济于事。
core.gitdir = / Users / braitsch / Test / git-dir / .git
现在,这里来了踢球。如果我将工作树设置为git-dir的父目录,则Git存储将可以工作如果我将worktree设置为我的主目录。
core.worktree = / Users / braitsch /
code>
所以我给你们的问题是我错过了什么设置让git允许我的工作树存在 任何地方 在文件系统上,而不仅仅是沿着git-dir的父路径备份到根目录?当然,一定有办法把你的git-dir&你的工作树无论你想要什么,并告诉GIT他们在哪里有一切工作?非常感谢您的阅读。任何见解都会得到慷慨的赞赏。
你的路径> --work-tree =<工作树路径>隐藏应该有效。您是否尝试了绝对路径?
更新:
似乎是一个错误。 --git-dir选项的扩展功能最近才被添加,一些像git存储这样的命令还没有新的实现。
git-stash是bash脚本。你可以破解它并删除需要的工作目录检查,然后cd进入工作文件夹。
I'm having a helluva time getting git to cooperate with my user-defined worktree that exists outside the folder that contains my .git directory.
Basically the setup is like this: I have two directories, one called "git-worktree" which houses the file I want to track & another called "git-dir" which contains the repository's .git folder aka the GIT_DIR.
I init the repository by cd'ing into folder "git-dir" and running:
git --git-dir=./.git --work-tree=/Users/braitsch/Test/git-worktree/ init
This successfully initializes the repository and while I'm in the "git-dir" folder I can add files that are in the work-tree, run git status and commit them. Cool.
The kick in the balls here comes when I try to run git stash which slaps me with the error:
fatal: /usr/local/git/libexec/git-core/git-stash cannot be used without a working tree.
Now this is BS because I know (or at least I think) I have the work-tree set to the "git-worktree" folder that contains the files I want to track.
git config --local -l shows me the following :
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.worktree=/Users/braitsch/Test/git-worktree
core.ignorecase=true
I even tried manually adding the .git folder to the local config file to see if that helps but to no avail.
core.gitdir=/Users/braitsch/Test/git-dir/.git
Now here come's the kicker. Git stash will work if I set the worktree to a directory that is a parent of the git-dir e.g. If I set the worktree to say my home directory.
core.worktree=/Users/braitsch/
So the question I have for you guys is what setting am I missing to tell git to allow my worktree to exist anywhere on the filesystem, not just along a parent path of the git-dir back up to the root? Surely there must be a way to place your git-dir & your work-tree wherever you want and after telling git where they are have everything work? Thanks much for reading. Any insights would be graciously appreciated.
git --git-dir=<your path> --work-tree=<work tree path> stash
should work. Have you tried absolute paths?
UPDATE:
seems to be a bug. The extended functionality of --git-dir option was only added recently and some commands like git stash don't have the new implementation yet.
git-stash is a bash script. You could hack it and remove the require working dir check then cd into the working folder.
这篇关于Git Stash& Worktree Woes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!