Committing changes to the Git repository
Now that you have pushed your source code out to Git, the next step is to “commit” the changes to Git. Git maintains a database of the changes to files every time you commit the changes. Therefore it is important to commit to Git on a regular basis, say daily or at the end of your coding session. There is no overhead to committing often. In fact the more often you commit, the better.
To commit your changes, you can either right-click in the C:\Revsoft\Git\star directory and select GitEx Commit or from the OpenInsight IDE, go to Git, Git Commit…
Figure 39 – Committing from Windows Explorer
Figure 40 – Committing from OpenInsight
The Git Extensions commit window will display.
Figure 41 – Git Extensions Commit window
Most Git clients will have a similar commit window. The upper left is your Working Directory and contains a list of all the files that have changed since your last commit. As you can see, each of these has the green plus icon which means that these are new files. Changes will have a pencil icon and deletes will have a red minus sign .
The upper right displays the contents of the file you selected in your Working Directory.
You must stage your changes from the Working Directory to the Staging Area in the lower left before you can commit.
Only files in the Staging Area will be committed. To move files from the Working Directory to the Staging Area, use the Stage buttons.
Move all your files to the Staging Area.
Before you commit you must add a comment. This comment is used to describe the purpose of this commit. You can type as much or as little as you like. The commit process will automatically add the date, time and your Git user details to the commit so there is no need to add these details.
Type the following commit comment:
My first commit of the entire repository
Now click the Commit button to commit these files to Git. Committing files is like taking a snap shot of the file at a point in time. You will be able to revert back to or look at these files as they were when you committed them.
Your commit window should look like this:
Figure 42 – Staged items prior to committing
When you click the Commit button a process window will appear. Your process window should look like this once it’s completed.
Figure 43 – Commit process window