git 如何在 Visual Studio 2013 中隐藏未提交的更改

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19618112/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:16:29  来源:igfitidea点击:

How do I stash uncommitted changes in Visual Studio 2013

gitvisual-studiovisual-studio-2013

提问by teh0wner

Need some help on how I can shelve uncommited changes in a Git repository using Visual Studio 2013. I come from PHPStorm where you can shelve uncommited changes on one branch, switch to another and unshelve.

需要一些关于如何使用 Visual Studio 2013 搁置 Git 存储库中未提交更改的帮助。我来自 PHPStorm,您可以在其中搁置一个分支上的未提交更改,切换到另一个并取消搁置。

However, I can't find/see how this can be done in Visual Studio. Could someone shed some light on this issue?

但是,我找不到/看到如何在 Visual Studio 中完成此操作。有人可以对这个问题有所了解吗?

Just to clarify why this may be needed: I might be working on branch X, and then figure that I am the wrong branch and I should be on branch Y. I need to shelve all changes from branch X, switch to branch Y, unshelve changes and then commit.

只是为了澄清为什么需要这样做:我可能在分支 X 上工作,然后认为我是错误的分支,我应该在分支 Y 上。我需要搁置分支 X 的所有更改,切换到分支 Y,取消搁置更改然后提交。

Thanks.

谢谢。

采纳答案by mah

In gitthe concept you're looking for is stash. You add your changes as if you are going to commit them, and you then stash them with git stash. After changing branches, you can git stash applyor git stash pop(with the former leaving the stash available for reuse).

git这个概念你要找的是stash。您添加更改就好像要提交它们一样,然后将它们存储在git stash. 更改分支后,您可以git stash applygit stash pop(前者保留可重复使用的存储库)。

I'm familiar with the shelfconcept from Perforce, which has a useful difference from Git's stash -- where you can send a shelf to the server and share it with other people, you cannot do that with git. However, with git you can just create a branch with the stash and push that to the server, allowing others to merge it where it's needed.

我熟悉shelfPerforce的概念,它与 Git 的 stash 有一个有用的区别——您可以将架子发送到服务器并与其他人共享,而使用 git 则无法做到这一点。但是,使用 git,您只需创建一个带有存储的分支并将其推送到服务器,允许其他人在需要的地方合并它。

Microsoft does not provide a way to use this feature.

Microsoft 不提供使用此功能的方法。

回答by thelem

Visual Studio 2013 Update 2 does not support shelving (called stashing in git) for git repositories, but you can use 3rd party tools on the repository itself (I use SourceTree).

Visual Studio 2013 Update 2 不支持 git 存储库的搁置(在 git 中称为 stashing),但您可以在存储库本身上使用 3rd 方工具(我使用 SourceTree)。

回答by Pugz

Maybe I showed up late to this one.

也许我来晚了。

I use TortoiseGit for this... It works really well and can work alongside Visual Studio as it is just an explorer plugin.

我为此使用 TortoiseGit...它工作得非常好并且可以与 Visual Studio 一起使用,因为它只是一个资源管理器插件。

https://tortoisegit.org/

https://tortoisegit.org/

回答by Homer

You can add Stash to Visual Studio by using this extension: GitStashExtension

您可以使用此扩展将 Stash 添加到 Visual Studio: GitStashExtension