{"id":1034,"date":"2015-09-17T08:35:22","date_gmt":"2015-09-17T08:35:22","guid":{"rendered":"http:\/\/invisiblezero.net\/?p=1034"},"modified":"2024-07-22T09:23:59","modified_gmt":"2024-07-22T09:23:59","slug":"gitignore-generator-for-magento","status":"publish","type":"post","link":"http:\/\/ndthanh.com\/gitignore-generator-for-magento\/","title":{"rendered":".gitignore generator for Magento"},"content":{"rendered":"\n
Git is a distributed revision control system with an emphasis on speed, data integrity, and support for distributed, non-linear workflows. it’s important for many projects and Magento is not an exception. for many beginners or even experienced developers, a good .gitignore file is not always in their mind, this is source of many sins in the future to other developers who get in the line of the same project later.<\/p>\n\n\n\n
i created a bash script and have been using it for awhile. You can generate a good .gitignore file from now on and stop worrying about git related issues in the future. you can find the script below<\/p>\n\n\n\n\n\n\n\n
#! \/bin\/bash\n# generate .gitignore\n# add rules to.gitignore automatically\n#author: Atheotsky\n \nGIT=.gitignore\n \n# find exception under a directory. $1 : directory, $2 keyword\ngetExceptions()\n{\nSUBDIRS=$(find $1 -type d -iname $2 | grep -i media | sort | awk '$0 !~ last \"\/\" {print last} {last=$0} END {print last}')\n}\n \nfind . -name '.svn' -depth -exec rm -rf {} \\;\nfind . -name '*_DS*' -depth -exec rm -rf {} \\;\nfind . -type d -empty -exec touch {}\/$GIT \\;\ntouch $GIT;\n \n#default rules\necho 'app\/etc\/local.xml' >> $GIT;\necho '.htaccess' >> $GIT;\necho 'app\/.htaccess' >> $GIT;\necho 'errors\/local.xml' >> $GIT;\necho 'tasks.txt' >> $GIT;\n \n#directories must have slash \/ to make sure git won't mistake it with file\necho '.idea\/' >> $GIT;\necho '.modgit\/' >> $GIT;\necho 'includes\/' >> $GIT;\necho 'media\/' >> $GIT;\necho 'nbproject\/' >> $GIT;\necho 'var\/' >> $GIT;\n \necho '.DS_Store' >> $GIT;\necho '*.swp' >> $GIT;\necho '*.swn' >> $GIT;\necho '*.swo' >> $GIT;\n \n#add exceptions - invoke function with param directory and keyword\necho '#files & folders exception' >> $GIT;\n \ngetExceptions 'app' 'media'\nfor line in $SUBDIRS\ndo\nprintf \"!%s\\n\" $line >> $GIT;\ndone\n \ngetExceptions 'skin' 'media'\nfor line in $SUBDIRS\ndo\nprintf \"!%s\\n\" $line >> $GIT;\ndone\n \ngetExceptions 'js' 'media'\nfor line in $SUBDIRS\ndo\nprintf \"!%s\\n\" $line >> $GIT;\ndone\n \n#do git initialize\ngit init;\ngit add . ;\ngit commit -m 'Initial Import';<\/code><\/pre>\n\n\n\ni added comments for each section, i hope you can get it without problem \ud83d\ude1b<\/p>\n","protected":false},"excerpt":{"rendered":"
Git is a distributed revision control system with an emphasis on speed, data integrity, and support for distributed, non-linear workflows. it’s important for many projects and Magento is not an exception. for many beginners or even experienced developers, a good .gitignore file is not always in their mind, this is source of many sins in…<\/p>\n