使用Git/Github for Windows,如果我有一个存储库的这个目录:C:\dir1\dir2,我需要做什么来移动回购文件到C:\dir1?显然,我可以物理地复制和粘贴文件,但在Git端需要做什么呢?
我在GitHub上有这个回购,我使用Git Bash和GitHub for Windows。
使用Git/Github for Windows,如果我有一个存储库的这个目录:C:\dir1\dir2,我需要做什么来移动回购文件到C:\dir1?显然,我可以物理地复制和粘贴文件,但在Git端需要做什么呢?
我在GitHub上有这个回购,我使用Git Bash和GitHub for Windows。
当前回答
更基于Git的方法是使用cd或复制粘贴对本地副本进行更改,然后将这些更改从本地存储库推到远程存储库。
如果您尝试检查本地回购的状态,它可能会显示“未跟踪的更改”,这实际上是重新定位的文件。要强制执行这些更改,您需要使用
$ git add -A
#And commiting them
$ git commit -m "Relocating image demo files"
#And finally, push
$ git push -u local_repo -f HEAD:master
希望能有所帮助。
其他回答
我不确定这个问题,所以这里有两个答案:
如果你想移动你的存储库:
简单地复制整个存储库(包括它的.git目录)。
在.git结构中没有绝对路径,也没有任何东西阻止它被移动,所以在移动之后你就没有什么可做的了。所有到github的链接(参见.git/config)将像以前一样工作。
如果你想将文件移动到存储库中:
只需移动文件。然后添加git status中列出的更改。下一次提交将执行必要的操作。您将很高兴地了解到不会复制任何文件:在git中移动文件几乎是零成本的。
这对我没用。我将一个repo从(例如)c:\project1\移动到c:\repo\project1\, Git for windows没有显示任何变化。
Git状态显示错误,因为其中一个子模块“不是Git存储库”,并显示旧路径。例如(为保护知识产权而更改名称)
C:/project1/.git/modules/subproject/subproject2 致命:“git状态—瓷器”在子模块子项目失败
我必须手动编辑子模块中的.git文件,以指向子模块的repo的正确相对路径(在主repo的.git/modules目录中)
-首先检查当前文件夹中包含git repo的所有目录 $ ls -la或者ls -al
-识别这个文件夹
**.git**
-使用此命令移动文件夹到您需要的位置,
$ mv .git你想要的目录
注意:>目录不会影响git的历史记录,也不会影响远程连接 考虑要移动到的目录的树(路径)
I use Github Desktop for Windows and I wanted to move location of a repository. No problem if you move your directory and choose the new location in the software. But if you set a bad directory, you get a fatal error and no second chance to make a relocation to the good one. So to repair that. You must copy project files in the bad directory, make its reconize by Github Desktop, after that, you can move again your project in another folder and make a relocate in the software. No need to close Github Desktop for that, it will check folders in live.
希望这能帮助到一些人。
更基于Git的方法是使用cd或复制粘贴对本地副本进行更改,然后将这些更改从本地存储库推到远程存储库。
如果您尝试检查本地回购的状态,它可能会显示“未跟踪的更改”,这实际上是重新定位的文件。要强制执行这些更改,您需要使用
$ git add -A
#And commiting them
$ git commit -m "Relocating image demo files"
#And finally, push
$ git push -u local_repo -f HEAD:master
希望能有所帮助。