Git commit ( git commit
) Command
git commit is for adding the work done into VCS,
so that you can publish your work with your colleague. Basically if you
commit something in your local repositoy by the command
git command -m "your commit message"
will store the changes locally, once you
push it to the remote repository then it is visible for others.
Before commit your changes you should check that which files are changed
by the command git status
this will list the files changes by
use, now you can add those files you want to commit by the command
git add < files name >
, after adding all those file you want to
commit will be visible in gree colour if you check the git status. Now you
are ready to commit by the following command.
git commit -m "Your commit message"
How do you changes you commit message?
In case you have add comment message which is not relevent or nor appropriate or have you type something wrong, then you could easily changes it by the following command
git commit --amend
and press Enter. The committed message
will be open in your vim or vi or whatever your default editor, edit the
message and save it.
How do you changes you commit message when you have already pushed to your remote branch?
In case you have already pushed to remote branch then use the following git commands to change the comment and again push it to remote branch.
First changes the comment
git commit --amend
and press Enter. The committed message
will be open in your vim or vi or whatever your default editor, edit the
message and save it.
Now push the branch again so that other can see your changes message
git push origin BranchName --force
or git push origin BranchName -f