If you complete IGETC at your community college before transfer to a UC or CSU, then CSUs and most UCs will consider that as fulfilling most or all lower division general education requirements (a few campuses or majors do not, such as UCB business or engineering). If you do not complete IGETC before transfer, or you transfer to a program that does not accept IGETC, then courses taken can fulfill some general education requirements on a course-by-course basis. Courses that fulfill IGETC categories can also fulfill requirements for your major.
Note that IGETC for CSU requires an oral communication course, while IGETC for UC requires some foreign language.
In most cases, it is preferable to prioritize major preparation courses (to the extent that they are available) over completing IGETC if you cannot schedule your courses to complete both while at community college. However, some courses must be completed before transfer, such as the https://admission.universityofcalifornia.edu/admission-requirements/transfer-requirements/preparing-to-transfer/basic-requirements.html for UCs and https://www2.calstate.edu/apply/transfer/Pages/upper-division-transfer.aspx for CSUs.
You can check http://www.assist.org for course articulation by major (although some UCs and CSUs may not have the by major listings for the latest academic year; check previous academic years but verify on the UC or CSU department web site to check if the requirements have changed).
There is a UC Transfers section of these forums, with some FAQ threads stuck at the top that you should read.