How to Transfer a Tracked File to Notrecked Using Visual Studio Tools for Git

Started experimenting with git. Inadvertently added all the files to the project in the "Included Changes" in Team Explorer. I did everything in the initial commit. One of these files was the SQL CE 4.0 database (file-based). I am clearly there. I do not want to track the database, and I do not want me to put db back to the previous point.

My problem is that I do not know how to transfer the SQL CE 4.0 sdf file from the included changes to untracked. I am not familiar with git, and all I know today is what is provided to me in the Team Explorer user interface.

So, how can I transfer a file from (perfect and) tracked to untested? Upon completion of the successful operation, I would like to have the sdf file in the "untrecked" bin and would like to remove it from the commits that were ported to the remote repo. I just don’t know where to start and what to do.

+5
source share
1 answer

To track it, simply delete it and commit, which will remove the database from the latest version of the repository. It is still easy from the Visual Studio interface. If you need to save the sdf, then copy it to a temporary location.

To remove it from git (and save it in place on the file system), you can issue the remove command from the command line . This is not easy to do from the Visual Studio user interface.

git rm --cached yourfile.sdf 

To completely remove an unnecessary file from the repository, you need to go to the command line . This will delete the file from your story.

WARNING This will overwrite the history, as a result of which all your commit IDs will be changed. Attention

 git filter-branch --prune-empty -dc:\temp\tempfolder --index-filter "git rm --cached -f --ignore-unmatch yourfile.sdf" --tag-name-filter cat -- --all 

The file will no longer be referenced and will be deleted from the repo at some point. To tell git to delete the file immediately, follow these steps:

 git update-ref -d refs/original/refs/heads/master git reflog expire --expire=now --all git gc --prune=now --aggressive 

Finally, copy these changes to your remote:

 git push origin --all --force 

This force push requires additional permissions in TFS. by default, only project administrators have this permission .

For more clarification, read related answers to related questions.

If your remote repo has branches that you do not have, you may need to pull all the branches first . You can do this using:

 git pull --all 
+5
source

All Articles