Git - git commit

git

git commit -a -s // commit everything, as you have tested, with your sign-off
git commit -a --amend // amend the previous commit, adding all your 
  // new changes, using your original message.

What is the purpose of the -m and -v options of the 'git commit' command?

If you don't pass any -m parameter or pass the -e parameter, your favorite $EDITOR will get run and you can compose your commit message there, just as with Subversion. In addition, the list of files to be committed is shown.

And as a bonus, if you pass it the -v parameter it will show the whole patch being committed in the editor so that you can do a quick last-time review.

How can we fix the commit message after the commit was done?

By the way, if you screwed up committing, there's not much you can do with Subversion, except using some enigmatic svnadmin subcommands. Git does it better . You can amend your latest commit (re-edit the metadata as well as update the tree) using git commit —amend, or toss your latest commit away completely using git reset HEAD^. This will not change the working tree. https://git-scm.com/course/svn.html

How can we share our work?

Your local repository can be used by others to pull changes, but normally you would have a private repository and a public repository. The public repository is where everybody pulls and you… do the opposite? Push your changes? Yes! We do git push remote which will push all the local branches with a corresponding remote branch - note that this works generally only over SSH (or HTTP but with special webserver setup). It is highly recommended to setup a SSH key and an SSH agent mechanism so that you don't have to type in a password all the time. https://git-scm.com/course/svn.html

What is the purpose of the 'git commit --amend' option?

You can use the –amend command when you need to alter a commit message or forgot to add some files. To change the commit message:

git commit --amend

To add a file to a commit:

$ git commit -m “my first commit”
$ git add example_file
$ git commit --amend
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License