# add specific file git add file_name # add all files git add .
git rm
over other methodsrm
removes file or directories from both the staging index and the working directory which is preferred over deleting the file in the file system and having Git detect the deletion
rm
will always lead to cleaner diff
git rm deleted_file_name # remove from index only, keep file in filesystem git rm --cached file_name
git restore
# unstage file_name from index git restore --staged file_name # ## Reset the file back to original state after unstaging git restore file_name
git checkout commit_hash -- file_path
git commit
--allow-empty
Creates an empty commit with no changes
git commit --allow-empty -m "fix CI"
--no-verify
Can be used to skip pre-hooks
git commit --no-verify
git amend
Modify the latest commit without creating a new commit
git commit --amend
git commit --amend -m "an updated commit message"