I noticed that whenever I duplicate a file in visual studio using copy paste, the git history of the original file is copied to the new file. How do we avoid this?
I expect the file to be considered as a new file rather than a clone of the existing file. Renaming the file doesn't remove the history.
Edit: I see that the old file's history is shown only in Visual studio's git history option. If I check the file history in bitbucket, it shows just the new file history. Even in visual studio code git plugin, the history is showing just what I expect. This seems like a bug in visual studio or some settings I need to turn off.
I am talking about the history we see by clicking the git history option in the context menu of the file in visual studio. Git history context menu
Git does not store the history of files across copies/renames. It merely assumes that a file is copied or moved if it finds a similar file in the repo when it scans the history. So whether something is a copy is determined while you inspect the history, not when you commit a change. It is therefore a setting of the client how intensively git tries to identify copies.
Some git clients (e.g TortoiseGit, see image) allow changing the follow-rename behavior.