Skip to main content

Git Commits

This guide goes over the commit tab of the Git Modal and making a commits to your repository.

Commits

When you open the Git Modal, it will show any changes made and automatically select all files to be staged. You'll need to deselect any files you don't want.

The image displays a snapshot of the GitLab web interface, with a user inspecting the alterations within a branch labeled main. A file named NewJob-1.yml is conspicuously new to the branch, accompanied by a commit message: What changed in this commit?
  1. Git Modal Header - The header will always show the Current Branch, the Current Commit and if there are any uncommitted changes. It will also indicate if you are on the Commit or Branches screen.
  2. Changes - Changes shows any changes that were made to the current branch. Each one shows the number of files modified. Click each file to see the changes made. Learn more in What Gets Committed.
  3. Manage Changes:
    1. Stage All - All files under changes are selected to be part of the next commit.
    2. Unstage All - No files are selected to be part of the next commit. You’ll need to select the files you want to commit. At least one file needs to be selected to make a commit.
    3. Discard All - Discard all changes that were made to the Workspace.
  4. File Differences - Changes in red are deletions and changes in green are additions.
    4. Previous will show the contents before changes were made.
    5. Current will show the contents after changes were made, or what the file looks like currently. See Viewing File Differences for an example.
  5. Commit Message - A commit message describes the changes that were made.
  6. Fetch - Fetch gets all changes from the repository. Including any changes made to the branch you are working on.

Viewing File Differences

To view changes to a specific file, click on it, and the two panes on the right will populate with the file's previous state in the left pane and its current state in the right pane. Scrolling through the file will show you patches of green and red, which denote where additions and deletions have occurred. In the following example, a LOWER() transformation was applied and the column N_COMMENT was deleted without a replacement.

The image is a screenshot of a code editor. The code editor displays a file named TARGET-STG_NATION.yml, formatted in YAML. The file comprises a series of nodes, each with a distinct name, description, and a set of properties delineated in key-value pairs.

Next to each file there will be a red, orange, or green dot.

  • Green - A new Node or other type created.
  • Orange or Yellow - There were changes to the data.
  • Red - The Node or other type was deleted.
This image shows a Git interface for committing changes. It displays three modified files with .yml extensions, each marked by a different colored dot and checkbox. The interface includes options to Stage All, Unstage All, and Discard All changes.

Making a Commit

  1. Select the files you want to Stage. If you need to make changes, you’ll need to make them in the Workspace. At least one file needs to be selected.
  2. Write your Commit Message. It should be short and descriptive.
  3. Commit and Push your changes.

If you have no more changes to display, the list on the left won’t have any files. If you didn't commit all files, the list will be reduced to show just those files. This will allow you to make multiple commits within one use of the Git Modal, following the same process outlined above. The uncommitted code will either need to be discarded or committed so that it no longer appears as a change when opening the Git modal in the future.

Discard Changes

  • To permanently roll back all changes to the code since the last commit to the Current Branch, click on the Discard All button. After accepting the warning, all code will be rolled back and the list of YAML files will be empty.
  • Individual YAML files can be rolled back, by clicking on the undo button.
The image depicts a version control interface, highlighting changes to files. The interface shows the current branch as main with a pending commit labeled test that has uncommitted changes. There are options to stage, unstage, and discard changes, with a prominent Discard Changes button highlighted in red next to individual files and a Discard All button for bulk actions.

Understanding the Commits

Commit Init commit (4e9ae5d1) is available in both the jobs-testing branch and main branch. The branch jobs-testing was created from the main branch at commit 4e9ae5d1 . That means jobs-testing contains any changes made in the main branch at the commit snapshot 4e9ae5d1.

A snapshot of a code repository is depicted, displaying two branches: jobs-testing and main. Currently, the jobs-testing branch is selected, with the main branch checked out. On the jobs-testing branch, two commits are visible. The most recent commit, authored by tjperry07, is dated 4 days ago, with the commit message removed column. Preceding this, another commit by tjperry07 is noted, bearing the message created graph, from 13 days prior. The main branch reflects a single commit by tjperry07, also from 13 days ago, labeled Init commit.

Git Commit Notes

  • The changes to the YAML files seen in the list, will include everyone’s changes who are working in the same Workspace (connected to the same Git Branch). It's best practice that everyone has their own Workspace to prevent confusion or accidentally removing each others work.
  • Opening the Git modal captures a snapshot of the code in the Workspace, at that particular time. There is no need to click on the ‘Fetch’ button, as this has already happened on entry to the page.
  • While the Git modal is open, if code is being changed by another user using the same Workspace, this will NOT be reflected, even if the ‘Fetch’ button is clicked. To include any last minute recent changes, simply close and re-open the Git modal.
  • When discarding changes, this will affect all other users who are working in the same Workspace. Therefore use this option cautiously and ideally only discard individual items rather than everything.