在git中,可以创建一个存储,将该存储推送到远程存储库,在另一台计算机上检索该存储,然后应用该存储吗?
或者是我的选择:
发布于 2009-10-11 10:47:03
不可能通过fetch或其他方式获取它,镜像refspec是fetch = +refs/*:refs/*
,即使stash是refs/stash
,它也不会被发送。显式的refs/stash:refs/stash
也不起作用!
这只会让人感到困惑,因为它不会获取所有的存储,只获取最新的存储;存储的列表是引用refs/stashes
的引用日志。
发布于 2011-03-10 00:22:58
注:我刚刚用24小时的git-fu重写了这个答案:)在我的shell历史中,整个shebang现在是三个一行程序。但是,为了您的方便,我对它们进行了解压缩。
这样,我希望您能够看到我是如何做事情的,而不是盲目地复制/粘贴东西。
这是一步一步来的。
假设是包含存储的~/OLDREPO中的源代码。创建不包含任何存储的测试克隆:
cd ~/OLDREPO
git clone . /tmp/TEST
将所有存储推送为临时分支:
git send-pack /tmp/TEST $(for sha in $(git rev-list -g stash); \
do echo $sha:refs/heads/stash_$sha; done)
在接收端循环以转换回stashes:
cd /tmp/TEST/
for a in $(git rev-list --no-walk --glob='refs/heads/stash_*');
do
git checkout $a &&
git reset HEAD^ &&
git stash save "$(git log --format='%s' -1 HEAD@{1})"
done
如果你愿意,清理你的临时分支
git branch -D $(git branch|cut -c3-|grep ^stash_)
做一个git stash列表,你会得到如下结果:
stash@{0}: On (no branch): On testing: openmp import
stash@{1}: On (no branch): On testing: zfsrc
stash@{2}: On (no branch): WIP on sehe: 7006283 fixed wrong path to binary in debianized init script (reported as part of issue
stash@{3}: On (no branch): WIP on debian-collab: c5c8037 zfs_pool_alert should be installed by default
stash@{4}: On (no branch): WIP on xattrs: 3972694 removed braindead leftover -O0 flag
stash@{5}: On (no branch): WIP on testing: 3972694 removed braindead leftover -O0 flag
stash@{6}: On (no branch): WIP on testing: db9f77e fuse_unmount_all could be starved for the mtx lock
stash@{7}: On (no branch): WIP on xattrs: db9f77e fuse_unmount_all could be starved for the mtx lock
stash@{8}: On (no branch): WIP on testing: 28716d4 fixed implicit declaration of stat64
stash@{9}: On (no branch): WIP on emmanuel: bee6660 avoid unrelated changes
在原始存储库上,相同的代码如下所示
stash@{0}: WIP on emmanuel: bee6660 avoid unrelated changes
stash@{1}: WIP on testing: 28716d4 fixed implicit declaration of stat64
stash@{2}: WIP on xattrs: db9f77e fuse_unmount_all could be starved for the mtx lock
stash@{3}: WIP on testing: db9f77e fuse_unmount_all could be starved for the mtx lock
stash@{4}: WIP on testing: 3972694 removed braindead leftover -O0 flag
stash@{5}: WIP on xattrs: 3972694 removed braindead leftover -O0 flag
stash@{6}: WIP on debian-collab: c5c8037 zfs_pool_alert should be installed by default
stash@{7}: WIP on sehe: 7006283 fixed wrong path to binary in debianized init script (reported as part of issue #57)
stash@{8}: On testing: zfsrc
stash@{9}: On testing: openmp import
发布于 2010-03-29 08:13:26
我参加聚会有点晚了,但我相信我找到了一些对我有用的东西,如果你们的情况相同或相似,也可能对你有用。
我正在开发它自己的分支中的一个特性。分支不会合并到master中并被推送,直到它完成,或者我已经提交了我觉得舒服的展示给公众。因此,当我想要将未暂存的更改传输到另一台计算机时,我要做的是:
[non-commit] FOR TRANSFER ONLY
“的提交消息进行提交,其中包含您希望通过transfered.git pull ssh+git://<username>@<domain>/path/to/project/ rb:lb
如果您以不同的方式访问存储库,则URL可能会有所不同。这将把来自该URL的更改从远程分支"rb“拉到本地分支"lb”。请注意,我有一个运行在我自己的计算机上的ssh服务器,并且能够访问way.
git reset HEAD^
(暗示--mixed
)的存储库。这会将头重置为指向“非提交”提交之前的状态。
来自git-reset(1):"--mixed
:重置索引,但不重置工作树(即,更改的文件将被保留,但不标记为提交) ...“
因此,您最终将对文件进行更改,但不会提交给master,也不需要存储。
但是,这将要求您在进行“非提交”的存储库中执行git reset --hard HEAD^
操作,因为该提交是垃圾。
https://stackoverflow.com/questions/1550378
复制相似问题