Git Commit

Git Tutorial

Git and GitHub

Git Contribute

Git Advanced

Git Undo

Git Commit

Since we have finished our work, we are ready move from stage to commit for our repo.

Adding commits keep track of our progress and changes as we work. Git considers each commit change point or “save point”. It is a point in the project you can go back to if you find a bug, or want to make a change.

When we commit, we should always include a message.

By adding clear messages to each commit, it is easy for yourself (and others) to see what has changed and when.

Example:

[user @localhost] git commit -m “First release of Hello World!”

[master (root-commit) 221ec6e] First release of Hello World!

3 files changed, 26 insertions(+)

create mode 100644 README.md

create mode 100644 bluestyle.css

create mode 100644 index.html

The commit command performs a commit, and the-m “message” adds a message.

The Staging Environment has been committed to the repo, with the message:

“First release of Hello World!”

Git Commit without Stage

When small changes are made, using the staging environment, feels like a waste of time. While it is possible to commit changes directly and skip the staging environment. The -a option will automatically stage every changed, already tracked file.

Let’s add a small update to index.html:

<!DOCTYPE html>

<html>

<head>

<title>Hello World!</title>

<link rel=”stylesheet” href=”bluestyle.css”>

</head>

<body>

<h1>Hello world!</h1>

<p>This is the first file in my new Git Repo.</p>

<p>A new line in our file!</p>

</body>

</html>

Using the –short option helps to see the changes in a more compact way:

[user @localhost] git status –short

M index.html

let’s commit it directly:

Example:

[user @localhost] git commit -a -m

“Updated index.html with a new line”

[master 09f4acd] Updated index.html with a new line

1 file changed, 1 insertion(+)


Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/u212091429/domains/mydevhelp.com/public_html/wp-includes/functions.php on line 5420

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/u212091429/domains/mydevhelp.com/public_html/wp-includes/functions.php on line 5420