Git Committing

	
	$ git commit -m "your message"
	

Making a commit is similar to making a save in a file. We're taking a snapshot of a git repository in time. When saving a file, we are saving the state of a single file. With Git, we can save the state of multiple files and folders together.

We use the git commit command to actually commit changes from the staging area. When making a commit, we need to provide a commit message that summarizes the changes and work snapshotted in the commit. The -m flag allows us to pass in an inline commit message


Undoing Things

	
	$ git commit --amend
	

One of the common undos takes place when we commit too early and possibly forget to add some files, or we mess up our commit message. If we want to redo that commit, make the additional changes we forgot, stage them, and commit again using the --amend option.

lets say we commit and then realize that we forgot to stage the changes in a file we wanted to add to this commit, we can do something like this

	
	$ git commit -m 'Initial commit'
	$ git add forgotten_file
	$ git commit --amend
	

The same commit-message editor fires up, but it already contains the message of our previous commit. we can edit the message the same as always, but it overwrites our previous commit.


Some Basic Guidelines


Ignoring Files

We can tell Git which files and directories to ignore in a given repository, using a .gitignore file.This is useful for files we know we NEVER want to commit, including:

Create a file called .gitignore in the root of a repository. Inside the file, we can write patterns to tell Git which files & folders to ignore: