dog attack

okay so i had gotten a new dog almost a year ago. he’s 7 years old. german shepherd . he was the first dog to ever really like me and one day about 6 months ago he attacked my sister (she probably woke him up) and tonight he was being a good boy until he came up and attack for petting him. my mom told me when he attacked my sister that they were going to get rid of the dog and put it to sleep. but now he loves my sister and hates me lol i really don’t wanna put him down just because he’s been my baby for a good year. what should we do ?