Hope you’ve introductory knowledge of git, if not you can refer to one of my git intro blog
So we know things till
git push which is pretty simple, lets get little deep where we can deal with some real life scenarios where we might have messed up and want to make things write.
Checked in with wrong email address/name
First thing, setup proper email and name so you won’t make the same mistake again. Little flashback to know how you can…
git config user.email "email@example.com" git config user.name "Iron Man"
now lets correct our mistake, that we commited with wrong email. You can confirm it with
git log that what email was used for that commit.
In the below example I made a mistake and checked-in with wrong email.
If it was the last commit then below command will resolve your issue. It ammends your last commit and updates the author, later you can push it to remote repository.
git commit --amend --author="Saurabh Londhe <firstname.lastname@example.org>"
If you already pushed it to remote then you might need to push it forcefully
git push origin master -f
- change user name of old commit
- Committed with wrong Commit message/ Update commit message
- Add files to last commit
- Revert last commit from local and remote
- remove or revert specific commit
- Forcefully push local branch to remote
- Resolve conflicts with Pull
- Resolve conflicts with rebase
- merge and rebase
- What is squash commit