Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup .gitignore for Windows?

Tags:

git

windows

I am setting up my first project in Git. How do I setup git-ignore file in Windows?

I am creating my first Rails project using Vagrant and trying to configure .gitignore in Windows

like image 871
Mahesh N Avatar asked Apr 20 '16 01:04

Mahesh N


People also ask

How do I create a .gitignore file?

Use your favorite text editor to open the file called . git/info/exclude within the root of your Git repository. Any rule you add here will not be checked in, and will only ignore files for your local repository.

How do I Gitignore a folder in Windows?

If you want to maintain a folder and not the files inside it, just put a ". gitignore" file in the folder with "*" as the content. This file will make Git ignore all content from the repository.

Where is global Gitignore Windows?

Also, the default and automatic global gitignore file is $HOME/. config/git/ignore .


1 Answers

It seems that for ignoring files and directories there are two main ways:

.gitignore

  • Placing .gitignore file into the root of your repo besides .git folder (in Windows make sure you see the true file extension and then make .gitignore.

  • Making global configuration %HOMEPATH%\.gitignore_global and running

    git config --global core.excludesfile %HOMEPATH%\.gitignore_global to add this to your git config.

Note: files tracked before can be untracked by running git rm --cached filename. This absolutely critical for repos that existed BEFORE you created the .gitignore

Repo exclude

For local files that doesn't need to be shared, you just add file pattern or directory to file .git\info\exclude. These rules are not committed, so are not seen by other collaborators in your project. These are machine specific configs.

like image 108
sarbada Avatar answered Nov 15 '22 23:11

sarbada