1.

Git Commit

Answer»

Git commit is used to record all the changes in the repository. The git commit will commit all the changes and make a commit-id for the same for tracking down the changes made as shown in the image below.

As shown in the image, the command git commit creates a commit-id to track down changes and commits all the changes to the git repository.

Command:

git commit
  • git commit -m

The -m along with the command lets us write the commit message on the command line.

Command:

git commit -m "Commit message"
  • git commit -am

The -am along with the command is to write the commit message on the command line for already staged files.

Command:

git commit -am "Commit message"
  • git commit -amend

The amend is used to edit the last commit. In case we need to change the last committed message, this command can be used.

Command:

git commit -amend
  • git rm

rm stands for remove. It is used to remove a collection of files. The git rm command is used to remove or delete files from the working tree and index.

Command:

git rm <file_name>

Now, if you use the command git status, it would show, that the file has been deleted.




Discussion

No Comment Found