Search code examples
gitvisual-studiolinkedfiles

Visual Studio git and Linked files


I have a Visual Studio Solution, and one of the projects uses a Linked Excel file that is used by multiple developers in various VS solutions, and is stored on a network share. It gets changed regularly, and I need to add it to the git repository for my VS solution. I can (and have) added it to my solution file as a "linked File", but when I click on it the git.Commmit menu item does not appear. The only menu item under git that I see is the SHow History menu item. How can I add the file to git ?


Solution

  • It depends on what's on the file system, as that's what Git is tracking.

    • If a linked file copies a file to the file system then what's copied to the file system can be tracked in Git.
    • If a linked file creates a kind of "placeholder file" on the file system which internally contains metadata referencing the actual file then that placeholder is a file that can be tracked by Git.
    • If a linked file creates an entry in the data of a .sln file or .csproj file or something similar in Visual Studio then that entry is part of the code and that code can be tracked by Git.

    I suspect the last option is likely what's happening here. In which case as far as Git is concerned no file was added, but code was changed. Simply commit that code change. But if the goal is for the actual file to be tracked by Git then you can copy the file to the file system within the Git repository and add it to the solution from there, not as a linked file but simply as a file.