Copieing git repository to another disk is dangerous ! Especially in combination with remotes set to local repositories !

3 messages, 3 authors, 2025-12-04 · open the first message on its own page

Copieing git repository to another disk is dangerous ! Especially in combination with remotes set to local repositories !

From: Skybuck Flying <hidden>
Date: 2025-12-04 03:59:21

First turn off auto-capitalization in windows 11 mail options->editor settings->auto capitalization.

Then I can try and mystify you with proper commands:

X:
cd X:\Vite\Repository\Mirror
git clone --mirror https://github.com/vitelabs/go-vite .

cd X:\Vite\Branch\Develop\Delphi
git clone -o Repository "X:\Vite\Repository\Mirror" .

Now copy the contents of this disk to a new disk... (virtual disks)

Read down below why this is dangerous
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Here is the problem and even solution:

Let's suppose this is copied to disk Z:

git remote -v will show:

X:\Vite\Repository\Mirror

In other words the remote is still pointing to the mirror on disk X !!!!

Any clones on disk Z will commit to disk X, leading to a big mess !

It's the drive letter !

It must be updated/changed ?!

Which leads to the question:

Can drive letters be avoided in git remotes ?

Using a powershell script the AI was also kinda stupid and nuked upstream/origin with changed drive path, leading to url loss but that is minor.

Anyway the AI had a solution to sync things back up on Z:

My own steps first:
Copy mirror from X: to Z:
Adjust the remote to point to Z: instead of X:

Then follow AI steps:

Step 1: Fetch the latest remote state

git fetch Repository

Step 2:  Stash any local changes and untracked files
This ensures nothing gets lost or overwritten:
git stash --include-untracked

Step 3: Fast‑forward your local branch to the remote tip
git reset --hard Repository/Branch/Develop/Delphi
•     This moves your local branch pointer to match the remote exactly.
Your working tree will now reflect the remote commit b6ff41f28/whatever

Step 4: Restore your stashed files if needed
git stash pop

If you had local edits or untracked files you wanted to keep, they’ll be reapplied here.

If conflicts appear, Git will mark them clearly so you can resolve.

Step 5. Verify alignment
git log --oneline Branch/Develop/Delphi -n 5
git log --oneline Repository/Branch/Develop/Delphi -n 5

→ Both should show the same commit history at the tip.

The slightly annoying thing is, this had to happen to 8 commits containing either large files or many many many thousands of files, fortunately my system is fast and git can handle and my system has lots of ram otherwise, OOPSIE.

Anyway I discovered this problem earlier on... ppfffieww...

All these steps were tried out and it worked, proving it's now the same again, and indeed the files were identical locally and remote, but had to known for sure:

Z:\Vite\Branch\Develop\Delphi>git log --oneline Branch/Develop/Delphi -n 5
b6ff41f28 (HEAD -> Branch/Develop/Delphi, Repository/Branch/Develop/Delphi) AI System Prompts added.
a8b3415ed GoToDelphi mappings added, existing and missing.
a7a3bcc12 golang compiler/runtime source code added.
7f8dfb45f vendor packages added.
b6e5e7b6e Gemini 3.0 Pro fixes to Log15 and common

Z:\Vite\Branch\Develop\Delphi>git log --oneline Repository/Branch/Develop/Delphi -n 5
b6ff41f28 (HEAD -> Branch/Develop/Delphi, Repository/Branch/Develop/Delphi) AI System Prompts added.
a8b3415ed GoToDelphi mappings added, existing and missing.
a7a3bcc12 golang compiler/runtime source code added.
7f8dfb45f vendor packages added.
b6e5e7b6e Gemini 3.0 Pro fixes to Log15 and common

Z:\Vite\Branch\Develop\Delphi>

(In my case the drive letters where U: and X: but I changed it in this example to X and Z)

Goodbye,
  for now,
    Skybuck Flying !

Re: Copieing git repository to another disk is dangerous ! Especially in combination with remotes set to local repositories !

From: Torsten Bögershausen <hidden>
Date: 2025-12-04 05:12:23

On Thu, Dec 04, 2025 at 03:59:19AM +0000, Skybuck Flying wrote:

[Skip all the interesting stuff]
Which leads to the question:

Can drive letters be avoided in git remotes ?
I think so.
Since a long time Windows supports an UNC path.
They start with a double backslash, followed by the
server and share:

\\server\share\directory\filename.txt
So when you do
net use z: \\server\share

you can do
git clone //server/share/path-to-repo
instead of
git clone z:/path-to-repo

(And git replaces '/' with '\' internally.)

I need to admit that this may be not well-known 
but should work.

Re: Copieing git repository to another disk is dangerous ! Especially in combination with remotes set to local repositories !

From: Konstantin Khomoutov <hidden>
Date: 2025-12-04 09:20:11

On Thu, Dec 04, 2025 at 03:59:19AM +0000, Skybuck Flying wrote:

[...]
X:
cd X:\Vite\Repository\Mirror
git clone --mirror https://github.com/vitelabs/go-vite .

cd X:\Vite\Branch\Develop\Delphi
git clone -o Repository "X:\Vite\Repository\Mirror" .

Now copy the contents of this disk to a new disk... (virtual disks)
git remote -v will show:

X:\Vite\Repository\Mirror

In other words the remote is still pointing to the mirror on disk X !!!!
I do not understand the problem: the command

  git clone -o Repository "X:\Vite\Repository\Mirror"
  
has cloned the repository "X:\Vite\Repository\Mirror", and so it is completely
expected that re so-called "remote" to which you gave the name "Repository"
records the URL of the remote repository it points at exactly as it has been
provided by the user - with the drive letter in this case.

If you do not want this behavior, you might consider using UNC paths or
a reasonably recent (2010s, I think) addition to NTFS called "junction points"
which allows you to mount an external drive "on" an empty filesysem folder -
almost UNIX-way, so to speak ;-) See the "mountvol" console command and [1].

 1. https://serverfault.com/a/8871
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help