Note that `git add .` will also add any new files in the path to the repository, if you only want to update existing without allowing random files to get added just use `git commit -a "latest changes"`
I tend to teach git a bit more ... disciplined than this. It's 100 times easier to make a git mistake than it is to fix it.
git status
git pull
git status
First and foremost, always. If this doesn't work, gets blocked or causes a merge hell, fix it FIRST.
Add files specifically where practical.
git add -u
git status
This adds "known and modified" files to the staging. running status lets git read back what you did and you to validate it didn't do something unexpected.... like add a whole bunch of build temp files.
git add src/main/blah.blah
git add src/main/newpackage/
git status
git reset src/main/newpackage/.garbage
echo '**/.garbage' >> .gitignore
git add .gitignore
git status
Your git status should be "clean". The more crude and cruft you build up in your "untracked" file list that don't go away on a "make clean" the more risk you have you forget to commit something.
When you are happy that the "staging" in green looks like what you want to comit...
git commit -m "TICKET_ID Blah blah something useful"
git pull
git push
The amount of crap you have to clean up when people just run stuff like:
git commit -a "Blah"
git commit .
Is formidable. Then you end up with somone commiting a build temp file but with their UID and 600 perms. Now nobody can build the app, not even the build servers.
A common mistake I see is not syncing the repos fully first. I am guilty of it myself. For a while I merge bombed myself multiple times. Commit ticket branch. Raise PR. Merge PR. Create new ticket branch. Work on ticket branch. Go to MR ticket branch and BOOM! So you face plam yourself and merge the main branch back into pick up your first ticket changes. Fixed? Nope. Your branch and the remote branch have the same code, same changes, but applied in a different order. Your options are to "rebase" your local commits into a new order and fix any conflicts OR take a deep breath and push and let git sort it out.