git pull origin master
git add .
git commit -m "bug x fixed"
Should I add them again? Should I remove the last commit and make a new one? or what?
What you are looking for is:
git add your_changes
git commit --amend
The amend
option will take the last commit and replace it by a new one with the previous changes and the new staged changes (new files, rename, delete...).
It should open the configurated editor with the message of the previous commit, you can replace it with a new message if you like by changing it.
Another option is to just keep committing as many times as you want since this is local. Then at the end, when you are ready, you can "squash" all your local commits into a single commit that is pushed up to the remote. There are a few ways to do this, but here is a link with a nice example (possibly one of the more flexible/easy ways): see top answer here
The advantage of this over things like "amend" is that you can keep all your commits and history locally so you have a better changes of going back if things go wrong or doing smaller diff etc... and all the hassle of going back and amending things later can be postponed to one time only all at the end when you are good and ready.... well, I prefer it that way anyway :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.