remove and exclude folder in git for upcomming commits 1

remove and exclude folder in git for upcomming commits

#Ensure to have added the directory, if not:

git add FolderName

#Steps to remove directory

git rm --cached FolderName -r
git commit -m "Removed folder from repository"
git push origin master

#Steps to ignore that folder in next commits

#To ignore that folder from next commits make one file in root named .gitignore
#and put that folders name into it. You can put as many as you want
#.gitignore file will be look like this:

/FolderName

Here is what the above code is Doing:
1. git rm –cached FolderName -r
This command will remove the folder from the repository but will keep the folder in your local system.
2. git commit -m “Removed folder from repository”
This command will commit the changes.
3. git push origin master
This command will push the changes to the remote repository.
4. To ignore that folder from next commits make one file in root named .gitignore and put that folders name into it. You can put as many as you want.
.gitignore file will be look like this:
/FolderName

Similar Posts