Reputation: 63
I want to move a typescript file in VSCode such that:
I can achieve either, but not both.
Using git mv: VSCode doesn't update the parent files' import statements.
Using manual drag & drop: git regards this as a new file.
How can I do both?
Upvotes: 1
Views: 493
Reputation: 63
After doing more research, it turns out git does not actually track file renames.
Compare:
After using git mv
, your git status
will return something like:
renamed: someFileName.ts -> newFileName.ts
After using mv
, your git status
will return something like:
deleted: someFileName.ts
untracked: newFileName.ts
^despite the apparent acknowledgement of a rename, git handles both scenarios identically.
After running git add -- someFileName.ts newFileName.ts
, you will get the same:
renamed: someFileName.ts -> newFileName.ts
Interestingly, this is not the norm for most SCMs. Linus explains the design decision here.
So to answer the original question: Use the VSCode integrated file explorer for file moves/renames - this updates import paths AND there is no detriment to version control.
Upvotes: 2