TFS命令的Git相当于什么搁置/不支持? 樱桃采摘?

我发现TFS中的shelve / unshelve命令非常方便,使用起来非常简单。 Git中的等价物是什么?

这里是TFS中的场景:

  • 我在后备箱中进行了更改
  • 我搁置:更改集保存在服务器上(带有标签),并在更改之前获取源代码
  • 我在后备箱里工作
  • 有人可以取消搁置:在工作区中设置更改

我知道有一个命令叫樱桃select,但我不确定的工作stream程,如果它符合需要。

你所描述的类似于git stash ,除了使用git你有自己的仓库(不只是一个服务器上的仓库),只有你可以得到这个变化。

总体思路是:

 # do some stuff vim foo/bar.c # stash away your changes git stash # do some other things... # retrieve your changes git stash pop 

如果你想让其他人访问这个变更集,你应该把它提交给一个工作分支:

 # make yourself a branch git checkout -b temp-featureA # commit to it git add foo/bar.c; git commit # now you push this branch (or they could just fetch straight from you) git push origin temp-featureA # Now, in someone else's repo: # Fetch updates git fetch origin # Make a branch tracking the remote branch git branch temp-featureA origin/temp-featureA # Either check it out: git checkout temp-featureA # or cherry-pick it, to apply the changes somewhere else: git cherry-pick temp-featureA # or, if it's multiple commits, rebase it! git rebase --onto my-branch start-of-featureA temp-featureA 

你想要做的是用git中的普通旧分支来完成。

JaredPar的 一个很好的StackOverflow答案 :

货架是一种在没有签入的情况下保存箱子上的所有更改的方法。更改将保留在服务器上。

这与提交分支并将其推送到git中的服务器类似。

怎么做:

假设您正在“主”分支上工作,并决定实施functionX.您可以从中获得一个良好的开端,但是上司会告诉您需要尽快实现functionY. 菲尔在下一个立方体的志愿者完成functionX,而你做functionY.以下是你的工作:

build立一个新的分支并切换到它:

 $ git checkout -b feature-x 

提交您的更改:

 $ git add filethatyouchanged.cc $ git commit -m 'partial implementation of feature X' 

将它推送到Phil可以看到的服务器:

 $ git push origin feature-x 

回到主分支(没有改变):

 $ git checkout master 

您可能还想主动为functionY创build一个新的分支:

 $ git checkout -b feature-y 

菲尔现在可以拉下你的functionX工作,并拿起你离开的地方:

 phil$ git fetch origin phil$ git checkout -t origin/feature-x 

git存储有点类似,除了它只限于你的工作树。

在DVCS中,要实现这种工作stream程,您需要:

  • 在新分支中提交当前的更改
  • 签出您可以继续的原始分支,而不会引入任何更改(但在新分支中提交)
  • 推新的分支到裸露的回购
  • 允许另一个开发人员将这个新分支合并到他当前的分支。

另一种方法是让另一个开发人员抓取你的分支(在那里你犯了一些特殊的变化),并挑选它 ,但是这不被推荐,因为樱桃挑选的提交很难跟踪 。

你在寻找隐藏的命令,我想。 参考