什么是相当于 TFS 命令搁置/取消搁置的 Git?樱桃? [英] what's the Git equivalent of TFS commands shelve/unshelve? cherry-pick?

查看:39
本文介绍了什么是相当于 TFS 命令搁置/取消搁置的 Git?樱桃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I found that the shelve/unshelve commands in TFS are very handy and very simple to use. What's the equivalent in Git ?

这是 TFS 中的场景:

here's the scenario in TFS :

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

我知道有一个命令调用cherry-pick,但我不确定工作流程是否符合需要.

I know that there's a command call cherry-pick but i"m not sure of the workflow and if it fits the need.

推荐答案

你描述的类似于 git stash,除了因为使用 git 您有自己的存储库(不仅仅是服务器上的单个存储库),只有您才能恢复该更改.

What you describe is similar to git stash, except since with git you have your own repository (not just a single one on a server), only you can get that change set back.

总体思路是:

# do some stuff
vim foo/bar.c
# stash away your changes
git stash

# do some other things...

# retrieve your changes
git stash pop

如果您希望其他人可以访问此变更集,您需要将其提交到工作分支:

If you wanted someone else to have access to this changeset, you'd want to instead commit it to a working branch:

# 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

这篇关于什么是相当于 TFS 命令搁置/取消搁置的 Git?樱桃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆