简体   繁体   English

在Windows计算机上更改GIT根目录

[英]Change the GIT root directory on a Windows computer

I installed GIT on my windows computer a few days ago, and set the root directory to my user's folder ( c:/users/user ). 几天前,我在Windows计算机上安装了GIT,并将根目录设置为用户的文件夹( c:/users/user )。 It added some folders and files (such as .git and .gitconfig ) to the user's folder and creates a bloated folder. 它将一些文件夹和文件(例如.git.gitconfig )添加到用户的文件夹中,并创建了一个.gitconfig肿的文件夹。

Now I'm interested in changing the root folder to an inner folder (which I'll name Programming). 现在,我有兴趣将根文件夹更改为内部文件夹(我将其命名为Programming)。
Can I change the root directory without harming the repositories I already have? 我可以更改根目录而不损害已经拥有的存储库吗? How can I do this from the console? 如何从控制台执行此操作?

You can leave the .gitconfig in place (it is your global Git configuration) 您可以保留.gitconfig到位(这是您的全局Git配置)

But a .git subfolder means you have initialized a repository in c:/users/user (as in " git init . "). 但是.git子文件夹意味着您已经在c:/users/user初始化了一个存储库(如“ git init . ”中)。
If you have added and committed all the files you need, you can: 如果已添加并提交了所需的所有文件,则可以:

  • create a new root folder elsewhere. 在其他位置创建一个新的根文件夹。
  • copy c:/users/user/.git in that new folder c:/users/user/.git复制到该新文件夹中
  • do a git checkout HEAD -- . 进行git checkout HEAD -- .
  • if everything works, then delete c:/users/user/.git That would move that repo in the new folder, and recreate its content. 如果一切正常,则删除c:/users/user/.git这将在新文件夹中移动该存储库,并重新创建其内容。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM