[英]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 : 执行步骤:
git checkout SHA1_OF_HEAD
or git checkout $(git rev-parse HEAD)
从新的hdd目录中,使用git checkout SHA1_OF_HEAD
或git checkout $(git rev-parse HEAD)
检出一个修订版(您希望的版本,但不是分支,以避免由于使用“工作树”功能而造成的限制git checkout $(git rev-parse HEAD)
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.