2010-02-11 40 views
17

一位同事在他的存储库中有一个存储,我可以访问(通过文件系统),并且我想将这个存储放入我的存储库中的一个分支。我可以从远程回购仓库取回一个本地分行吗?

 
% git ls-remote ~alice/work/repo/ stash 
3ccc82fb1ee0e7bde1250c7926d333ce21c109c0  refs/stash 

但当我尝试获取的是,git的告诉我:“无法找到3cc82 ......”

 
% git fetch ~alice/work/repo stash:new_branch 
remote: Total 0 (delta 0), reused 0 (delta 0) 
error: unable to find 3ccc82fb1ee0e7bde1250c7926d333ce21c109c0 
fatal: object 3ccc82fb1ee0e7bde1250c7926d333ce21c109c0 not found 

有没有一种方法,我可以获取远程藏匿?

回答

8

更新:直接回答楼主的问题是:

git send-pack ./ 3ccc82fb1ee0e7bde1250c7926d333ce21c109c0:refs/heads/tempbranch 

'tempbranch' 将在从遥控器上的最新藏匿(藏匿@ {0})。不幸的是,我不认为reflog是从远程分支中获取的,所以除非你有权访问源代码库,否则无法获取其他的信息。

脚本它:我在中提到的问题发布了一个更全面的“照本宣科”的解决方案在

Is it possible to push a git stash to a remote repository?

而且,我在此期间发现,混帐送包可以器乐如果你有权访问源回购:

git send-pack ../myworkingfolder/ [email protected]{0}:refs/heads/collegue_stash 
+0

谢谢,我看到了(并向上投票)。然而,这个问题试图解决一个不同的问题;我可以看到远程回购,但我的同事藏起来而不是承诺,然后回家告诉我关于藏匿的事情,所以我只想抓住那个藏匿处。一些更长时间的解决方案呈现自己(例如制作补丁并将其应用到本地),但我一直在寻找一种直接方式将隐藏存储到我的回购库中。 – 2011-03-11 22:17:58

+0

编辑点评与更多见解 – sehe 2011-03-13 02:40:40

+0

哦,好!谢谢! – 2011-03-13 04:29:49

1

你不能但这为你提供一个替代路径。 is-it-possible-to-push-a-git-stash-to-a-remote-repository

+0

嗨naven87。我确实看到了其他问题,但它不符合我的需要。感谢您的回答,如果没有人发布更直接的解决方案,我会在一段时间后接受它。 – 2010-02-13 05:52:48

+0

行,接受。谢谢naven87。 – 2010-03-05 03:28:56

8

是的,你可以,部分。 stash只是另一个ref。您可以通过指定refspec与全部ref路径来获取不是头的分支(分支)。

git fetch some-remote +refs/stash:refs/remotes/some-remote/stash 
git stash apply some-remote/stash 

最多可以配置此当你运行一个普通的获取,也获取藏匿:

git config --add remote.some-remote.fetch +refs/stash:refs/remotes/some-remote/stash 
git fetch some-remote 
git stash apply some-remote/stash 

但如果有一个“无效的Refspec”作为裁判没有藏匿这将失败不存在,所以你可能会更好地按需提供。您可以设置一个别名,如:

cat > /usr/local/bin/git-fetch-stash 
git fetch --verbose "$1" +refs/stash:refs/remotes/"$1"/stash 
^D 
chmod +x /usr/local/bin/git-fetch-stash 

git fetch-stash some-remote 

需要注意的是,您无法获取多个窗口。这些存储为reflog中的条目,并且无法获取远程的引用日志。

+2

这应该是接受的答案 – HerrSerker 2015-08-28 12:28:33

+0

同意。第一个git fetch + git存储对是神奇的。 – 2016-02-02 01:17:54

相关问题