Skip to main content
Active reading [<https://en.wiktionary.org/wiki/extension#Noun> <https://www.youtube.com/watch?v=1Dax90QyXgI&t=17m54s>]. Removed historical information (that is what the revision history is for)—the answer should be as if it was written right now.
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

First create a .gitignore.gitignore file where we have to store the names of files and directories to be ignored. To

To ignore a directory;

name_of_directory/ 

To ignore a file;

name_of_file 

We don't need to provide the complete path of the file or directory to be ignored,ignored; we just have to provide its name.

If you want to ignore all files with same extention;extension;

*.pyc #will ignore all files with pyc extention 

EDIT:

Also the above things will only work at the first time when you have not added the files to the gitGit. But if my mistake you added a file to the gitGit and now you want it to be ignored for the rest of the commits, you need to first clear the gitGit cache regarding that file by running this command;

git rm -r --cached <path_of_the_file> 

And the rest is the same, i.e, add the name to the .gitignore file.

First create a .gitignore file where we have to store the names of files and directories to be ignored. To ignore a directory;

name_of_directory/ 

To ignore a file;

name_of_file 

We don't need to provide the complete path of the file or directory to be ignored, we just have to provide its name.

If you want to ignore all files with same extention;

*.pyc #will ignore all files with pyc extention 

EDIT:

Also the above things will only work at the first time when you have not added the files to the git. But if my mistake you added a file to the git and now you want it to be ignored for the rest of the commits, you need to first clear the git cache regarding that file by running this command;

git rm -r --cached <path_of_the_file> 

And rest is same, i.e, add the name to the .gitignore file.

First create a .gitignore file where we have to store the names of files and directories to be ignored.

To ignore a directory;

name_of_directory/ 

To ignore a file;

name_of_file 

We don't need to provide the complete path of the file or directory to be ignored; we just have to provide its name.

If you want to ignore all files with same extension;

*.pyc #will ignore all files with pyc extention 

Also the above things will only work at the first time when you have not added the files to Git. But if my mistake you added a file to Git and now you want it to be ignored for the rest of the commits, you need to first clear the Git cache regarding that file by running this command;

git rm -r --cached <path_of_the_file> 

And the rest is the same, i.e, add the name to the .gitignore file.

added 417 characters in body
Source Link
Irfan wani
  • 5.3k
  • 2
  • 32
  • 49

First create a .gitignore file where we have to store the names of files and directories to be ignored. To ignore a directory;

name_of_directory/ 

To ignore a file;

name_of_file 

We don't need to provide the complete path of the file or directory to be ignored, we just have to provide its name.

If you want to ignore all files with same extention;

*.pyc #will ignore all files with pyc extention 

EDIT:

Also the above things will only work at the first time when you have not added the files to the git. But if my mistake you added a file to the git and now you want it to be ignored for the rest of the commits, you need to first clear the git cache regarding that file by running this command;

git rm -r --cached <path_of_the_file> 

And rest is same, i.e, add the name to the .gitignore file.

First create a .gitignore file where we have to store the names of files and directories to be ignored. To ignore a directory;

name_of_directory/ 

To ignore a file;

name_of_file 

We don't need to provide the complete path of the file or directory to be ignored, we just have to provide its name.

If you want to ignore all files with same extention;

*.pyc #will ignore all files with pyc extention 

First create a .gitignore file where we have to store the names of files and directories to be ignored. To ignore a directory;

name_of_directory/ 

To ignore a file;

name_of_file 

We don't need to provide the complete path of the file or directory to be ignored, we just have to provide its name.

If you want to ignore all files with same extention;

*.pyc #will ignore all files with pyc extention 

EDIT:

Also the above things will only work at the first time when you have not added the files to the git. But if my mistake you added a file to the git and now you want it to be ignored for the rest of the commits, you need to first clear the git cache regarding that file by running this command;

git rm -r --cached <path_of_the_file> 

And rest is same, i.e, add the name to the .gitignore file.

Source Link
Irfan wani
  • 5.3k
  • 2
  • 32
  • 49

First create a .gitignore file where we have to store the names of files and directories to be ignored. To ignore a directory;

name_of_directory/ 

To ignore a file;

name_of_file 

We don't need to provide the complete path of the file or directory to be ignored, we just have to provide its name.

If you want to ignore all files with same extention;

*.pyc #will ignore all files with pyc extention