gpt4 book ai didi

git - TFS 命令搁置/取消搁置的 Git 等价物是什么? cherry-pick ?

转载 作者:IT王子 更新时间:2023-10-29 00:34:18 26 4
gpt4 key购买 nike

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

这是 TFS 中的场景:

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

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

最佳答案

您描述的内容类似于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 - TFS 命令搁置/取消搁置的 Git 等价物是什么? cherry-pick ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3069979/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com