I've done this and it can be a little tricky, but generally as long as the curriculum is pretty close then you'll get credit. All the UC's determine this independently, so you may have a higher GPA at some because they'll count it as being equivalent and replace your grade or they won't and will just factor in both grades.
When I applied I repeated an English course that I retook at a separate CC and all the UC's accepted it as an equivalent except for UCSC. So my transferable GPA was near a 3.7 for most of the UCs and closer to a 3.5 for UCSC. Obviously, if you can the best thing would be to repeat it at your current community college. However, if you go to ASSIST.org and both the classes articulate to the same course at a particular UC then you should be good to go. Otherwise, you'll just have to apply and you won't definitively know whether it counted as a replacement or not until after your decision comes out and they're able to go over their evaluation with you on the phone. Unfortunately, calling beforehand doesn't help much. You can explain to them and they'll look up the courses, but mostly likely the best answer you'll get is a "probably" or an "I think..." from an admission officer. They really don't know until they have your application in hand and review it.