简体   繁体   English

Git Repo远程更改文件夹

[英]Git repo remote change folder

I created a git repository in folder A. And then, I push it to a remote (let's say it's called D) Then, I delete folder A, and create a new folder B with very different files/folders inside it. 我在文件夹A中创建了一个git存储库。然后,将其推送到一个远程文件夹(假设它称为D)。然后,我删除了文件夹A,并创建了一个新文件夹B,其中包含非常不同的文件/文件夹。 And, I want to change the remote D so it's pointing to B. 而且,我想更改远程D,使其指向B。

How to do it? 怎么做? thanks 谢谢

  1. Initialize a new git repository in B: git init 在B中初始化一个新的git仓库: git init
  2. Add all files in B: git add . 将所有文件添加到B: git add .
  3. Commit: git commit -a -m "Initial commit" 提交: git commit -a -m "Initial commit"
  4. Add D as a remote git remote add origin <D> 将D添加为远程git remote add origin <D>
  5. Force push to D: git push -fu origin master 强制推送到D: git push -fu origin master

This will destroy the history on D, so beware and if some one else is referring to that remote it might piss them off. 这将破坏D上的历史记录,因此请注意,如果其他人引用该远程服务器,可能会惹恼他们。

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

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