Quick Reference - Using Git - Committing to a repository


Commiting and pushing changes to the Git repository server

Quick jump: Using Git Bash | Using Git GUI

Using Git Bash

In your Windows Explorer, navigate to your repository folder. From within this folder, right-click some empty space and then click Git Bash Here.

Mac/Linux users: Open up the Terminal program.

If you cloned your repository in your home folder, use cd FOLDERNAME to move into that folder. Then you can run your git commands. Use ls to view a list of all files and folders in the directory you're in.

 

Use the following commands to add all changes and see a list of changes:

git add .
git status

 

Next, do a commit message. Make sure to put a description about what you changed after the -m and within double-quotes.

Instead of putting "DESCRIPTION", put a message about what you've updated in the double quotes. For example, if you're doing the first git set up, you could put "u01eA Git Setup" or "Git Setup".

git commit -m "DESCRIPTION"
 

To be on the safe side, do a git pull to see if there were any changes from the server. Afterward, do git push to push your changes to the server.

If this is your first time making a push, Windows will ask you for a Login. This should be the Username and Password for your GitLab account.

 

When the push is successful it will look like this.

 

Using Git GUI

In your Windows Explorer, navigate to your repository folder. From within this folder, right-click some empty space and then click Git GUI Here.

 

If any files have changed, it will show those files under Unstaged Changes (in red). Click on the Stage Changed button to add any changed files as ready to commit. They will then go into the green region, Staged Changes (Will Commit).

 

Add a message in the Commit Message: textbox. This should be a message of what you've updated so that you can easily find it later if needed.

After setting a message, click on Commit. The changed file information will disappear.

 

Next you should pull down changes from the server, just in case. Go to Remote and select Fetch from and then origin.

A status box will pop up afterwards, and you can close it.

 

After you're done committing, use the Push button. A window will pop up. Use the defaults and then click Push.

 

You'll see a status message that will either say Success or give you an error.