FIX: VSC source control show unknown files to commit to branch

Committing 10k+ files to a branch you haven’t heard of (or even main/master)?

The tutorial can work for other tools using git as well.

Do you see a list of changes in Visual Studio Code Source Control?
A list of changes that don’t seem familiar to you, like below?

FIX: VSC source control show unknown files to commit to branch
FIX: VSC source control show unknown files to commit to branch

Directories, git, source control and unknown files

Git works via a .git directory in which the changes are processed. This way, git knows which files need to be pushed to the relevant branch.
You may sometimes see files that do not match the expected source control.

This happens because you have a .git directory somewhere that shouldn’t be there, or in a different location.

Committing 10k+ files to a branch you haven't heard of (or even main/master)?
Committing 10k+ files to a branch you haven’t heard of (or even main/master)?

I opened Temp and expected that source control would use the .git folder in the Optimized.aza directory, but because there is also a .git in the root, it uses this as source control and I see files with changes that are in root .

.git directories are often hidden folders, do not forget to check the box Hidden items.

FIX: VSC source control show unknown files to commit to branch
FIX: VSC source control show unknown files to commit to branch

By removing the .git folder, the correct .git folder will be used again in the Optimized.Aza directory.

Committing 10k+ files to a branch you haven't heard of (or even main/master)?
Committing 10k+ files to a branch you haven’t heard of (or even main/master)?

Conclusion

Are you seeing files in Git that you wouldn’t want to see? It could be that an unexpected change has been made to the files, or there is a git directory somewhere that you need to adjust (or remove).

If you no longer want to see source control, or, for example, want to make a local backup of a branch, it is best to delete the .git directory because otherwise you can still push files to the branch in question and this can lead to unexpected situations in your development and in your main / master branch eventually.

Published by

Bas Wijdenes

My name is Bas Wijdenes and I work as a PowerShell DevOps Engineer. In my spare time I write about interesting stuff that I encounter during my work.

Leave a Reply

Your email address will not be published. Required fields are marked *