简体   繁体   English

在Visual Studio 2019中,是否可以将本地源代码控制存储库设置为解决方案文件夹以外的其他位置?

[英]In Visual Studio 2019, can I set my local source control repository to somewhere other than in my solution folder?

Visual Studio 2019 Community, Win10 Pro 64 Visual Studio 2019社区,Win10 Pro 64

I'm new to VS 2017 and 2019 and not all that familiar with git, but I have been able to set up a git repository and commit my solution to all the way to the remote server, using VS. 我是VS 2017和2019的新手,并且对git并不很熟悉,但是我已经能够建立git存储库,并使用VS将我的解决方案提交到远程服务器。 If I understand this correctly, the files are first stored into a repository that exists on my local machine, and then I commit it to the repository on the git server. 如果我正确理解,文件将首先存储到本地计算机上的存储库中,然后将其提交到git服务器上的存储库中。

While this all works just fine, I can't figure out how to place that local repository somewhere other than in my solution folder. 尽管这一切都很好,但是我无法弄清楚如何将本地存储库放置在解决方案文件夹之外的其他位置。 When I click on File->Add to Source Control in VS, it always adds it in a .git folder in my solution folder, and I can't figure out a way to put it somewhere else. 当我在VS中单击“ 文件”->“添加到源代码管理”时,它总是将其添加到我的解决方案文件夹中的.git文件夹中,而我想不出一种将其放置在其他位置的方法。

The reason I want to do this is that I do my development on an SSD for speed, but I want my local repository on an HDD so it doesn't consume space on the SSD. 我之所以想这样做,是因为我在SSD上进行开发以提高速度,但是我希望将本地存储库放在HDD上,这样就不会占用SSD上的空间。

Is there any way to set this up with Visual Studio 2019? 有什么方法可以使用Visual Studio 2019进行设置吗?

You can do nothing from VS but you can do it by relying on the command line. 您无法从VS执行任何操作,但可以依靠命令行来执行此操作。 Once it is set, you could you VS normally without problems. 一旦设置好,您就可以正常使用VS了。

There is a way to set the '.git' folder in another directory when you init or clone a repository. 初始化或克隆存储库时,有一种方法可以在另一个目录中设置“ .git”文件夹。 See: https://stackoverflow.com/a/19548676/717372 参见: https : //stackoverflow.com/a/19548676/717372

But you could also easily achieve what you want using the 'git worktree' feature. 但是,您也可以使用“ git worktree”功能轻松实现所需的功能。

Do the steps : 执行步骤:

  • Verify that all the files are committed or stashed (you have a clean working directory) 确认所有文件都已提交或保存(您有一个干净的工作目录)
  • move all the folder on your hdd. 移动硬盘上的所有文件夹。
  • From inside the new hdd directory, checkout a revision (the one you wish, but not a branch, to avoid a limitation due to use the 'worktree' feature) with git checkout SHA1_OF_HEAD or git checkout $(git rev-parse HEAD) 从新的hdd目录中,使用git checkout SHA1_OF_HEADgit checkout $(git rev-parse HEAD)检出一个修订版(您希望的版本,但不是分支,以避免由于使用“工作树”功能而造成的限制git checkout $(git rev-parse HEAD)
  • Create and use a worktree on your ssd with git worktree add c:\\path\\to\\ssd master 使用git worktree add c:\\path\\to\\ssd master worktree在ssd上创建并使用工作树, git worktree add c:\\path\\to\\ssd master
  • Now you can work in the ssd folder from VS 现在您可以在VS的ssd文件夹中工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何整理我的Git本地存储库(我使用了XCode的Source Control) - How can I straighten out my Git local repository (I used XCode's Source Control) 如何在已经存在的本地 git 存储库上设置 Visual Studio 2019? - How do I set up Visual Studio 2019 on a local git repository which already exists? 如何设置Xcode源代码控制,以便两台MacBook可以访问我的存储库? - How do I set up Xcode source control so that my repository can be accessed by two MacBooks? 我可以将我的本地 Github 存储库与 WAMP localhost 文件夹结合起来吗? - Can I combine my local Github repository with WAMP localhost folder? 如何将特定文件夹从来源(远程存储库)拉入本地主存储库 - How can i pull a specific folder from origin (Remote repository) into my local master repository 我将项目添加到我的Git存储库中,但它不在TFS源代码管理中 - I added my project to my Git Repository but it is not in TFS source control 将来自GitHub的现有项目添加到我的本地Visual Studio解决方案中 - Add existing project from GitHub to my local Visual Studio Solution Visual Studio - 解决方案目录外的源代码控制 - Visual Studio - Source control outside solution directory 我应该将Visual Studio 2015 .vs文件夹添加到源代码管理中吗? - Should I add the Visual Studio 2015 .vs folder to source control? 从Visual Studio解决方案中删除项目后,如何从Git存储库中删除Visual Studio 2015项目? - How do I remove a Visual Studio 2015 project from my Git repository after I remove that project from my Visual Studio solution?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM