michasaucer
michasaucer

Reputation: 5228

Properly set of .gitignore file in folder

I have a Repository on git with 2 folders.

enter image description here

One is ASP .NET Core Webapi, second is an React app. In main folder, i set .gitignore file genereted by Visual Studio 2017 by Git Settings but it dont work properly.

When i add migration into my database, i get a lot of not necesery changes:

enter code here

My question is, where add gitignore file to make it work properly? Or how to set it for working with Visual Studio, React and .NET Core in same way?

Upvotes: 0

Views: 618

Answers (1)

joran
joran

Reputation: 2883

First, git can only ignore untracked files.

where add gitignore file to make it work properly?

You can have different locations for such file(s), under your home directory (i.e. $HOME/.config/git/ignore), $GIT_DIR/info/exclude, $GIT_DIR/.gitignore and $GIT_DIR/**/.gitignore (see git help ignore what is supported in your version of git).

Adding a pattern to the ignore file under your home directory will apply to all local git repositories.

$GIT_DIR/info/exclude only applies to the local repo, cannot be shared with your teammates.

$GIT_DIR/.gitignore and $GIT_DIR/**/.gitignore can be tracked by git and can be shared with your teammates.

A pattern like *.txt will exclude any txt-file in the same directory and any subdirectories as .gitignore. A pattern like /*.txt will exclude any txt-file in the same directory as .gitignore.

A pattern like !a*.txt will include files matching this expression (even if it may have been excluded by some other ignore file).

You can use git check-ignore -v <pathname> to check what ignore expression is including/excluding a file or directory.

Upvotes: 1

Related Questions