Automated Version Control


Figure 1

Changes Are Saved Sequentially

Figure 2

Different Versions Can be Saved

Figure 3

Multiple Versions Can be Merged

Setting Up Git


Creating a Repository


Figure 1

File Explorer will show the hidden .git file that is created when you run `git init`.

Tracking Changes


Figure 1

mars.txt shown in File Explorer

Figure 2

The Git Staging Area

Figure 3

The Git Commit Workflow

Ignoring Things


Figure 1

The five files just created displayed in File Explorer

Remotes in GitLab


Figure 1

Creating a Project on GitLab (Step 1)

Figure 2

Creating a Project on GitLab (Step 2)

Figure 3

Creating a Project on GitLab (Step 3)

Figure 4

Creating a Project on GitLab (Step 4)

Figure 5

The Local Repository with Git Staging Area

Figure 6

Freshly-Made GitLab Repository

Figure 7

Where to Find User Settings on GitLab

Figure 8

Screenshot of Access tokens page and Add new token button

Figure 9

Add a personal access token screen in GitLab with Token name entered and all scopes selected

Figure 10

Screenshot of GitLab's presentation of your new personal access token

Figure 11

Where to Find Repository URL on GitLab

Figure 12

GitLab Repository After First Push

Exploring History


Figure 1

A screenshot showing a red box circling the button 'History' on the main page of the repository
Screenshot showing where to click ‘History’ in the GitLab repository main page

Figure 2

A screenshot showing what was added to mars.txt in a single commit
Screenshot showing GitLab’s commit diff interface

Branching and Merging


Figure 1

Screenshot of the `Create merge request` button

Figure 2

Screenshot of the Merge Request

Collaborating


Figure 1

screenshot of repository page with Manage then Members selected, showing how to add Collaborators in a GitLab repository

Figure 2

screenshot of the repository page with the Code menu opened and showing the copy button under Clone with HTTPS

Conflicts


Figure 1

Screenshot adding the line "This line was added to the copy in GitLab." in GitLab

Figure 2

The Conflicting Changes

Figure 3

Screenshot of mars.txt in GitLab with the merged content

Open Science


Policy


Licensing


Citation


Commonly Included Files


Figure 1

Screenshot showing a red circle around where to click to create a new file in a GitLab repository
Screenshot of adding a new file to a GitLab repository

Figure 2

Screenshot showing red boxes around where to click to rename the file, where to add the new text, and where to click "Commit"
Screenshot of renaming the file, the pasted text, and the commit button with numbers indicating the order of tasks

Figure 3

Screenshot showing the box where you can write a commit message in the Gitlab interface
Screenshot of the commit message

Creating Metadata


Figure 1

Screenshot showing a red circle around where to click to create a new file in a GitLab repository
Screenshot of adding a new file to a GitLab repository

Figure 2

Screenshot showing a red circle around where to click to create a new file in a GitLab repository
Screenshot of adding a new file to a GitLab repository

Figure 3

Screenshot of writing a commit message for adding the code.json file to a GitLab repository
Screenshot of adding a code.json template to a GitLab repository

Figure 4

Screenshot of clicking Edit on the code.json file in the web browser
Screenshot of editing a file in GitLab

Figure 5

  • Must use the raw variant of the file, which provides access to the plain text of the file and not the GitLab-formatted text. To get the raw variant of a file, click into the file, and click the Open raw button next to the Download button: Screenshot of red circle around a button that will Open Raw version of a file

  • Figure 6

  • In GitLab, you can get the download URL by selecting Code–> right click zip (under Download source code) –> Copy Link: Screenshot of red circle showing where to click Code, zip, and Copy link buttons to get the download url

  • Figure 7

    Diagram created with learngitbranching
    Diagram demonstrating the git flow for the creation of the initial code.json in the main branch of a repository. Please note that time progresses from top to bottom and arrows point to where the commit originated. The circle on the code.json indicates the commit where that version of the code.json file was created.

    Figure 8

    Diagram created with learngitbranching
    Diagram demonstrating the git flow for the addition of version 1.0.0 metadata in code.json, creation of the release candidate branch, and update of the DISCLAIMER file in branch 1.0.0. Please note that time progresses from top to bottom and arrows point to where the commit originated. The circle on the code.json document indicates the commit where that version of the code.json file was created.

    Figure 9

    Diagram created with learngitbranching
    Diagram demonstrating the git flow for the continued development in the main branch after the release of version 1.0.0. Notice that the code.json in 1.0.0 and main are still the same. Please note that time progresses from top to bottom and arrows point to where the commit originated. The circle on the code.json document indicates the commit where that version of the code.json file was created.

    Figure 10

    Diagram created with learngitbranching
    Diagram demonstrating the git flow for the addition of version 2.0.0 metadata in code.json, creation of the release candidate branch, and update of the DISCLAIMER file in branch 2.0.0. Notice that the code.json files in 2.0.0 and main are now different from the code.json file in 1.0.0. Please note that time progresses from top to bottom and arrows point to where the commit originated. The circle on the code.json document indicates the commit where that version of the code.json file was created.

    Software Review for Authors


    Figure 1

    Navigate to Merge requests in the GitLab side navigation and select New merge request: Screenshot of `Merge requests` in the side navigation and the `New merge request` button


    Figure 2

    Select main as the source branch and 1.0.0 as the target branch: Screenshot of the New merge request source branch and target branch selection


    Figure 3

    Screenshot of `Housekeeping` in the project advanced general settings.

    Software Review for Reviewers


    Figure 1

  • Navigate to Code -> Commits Screenshot of the menu to use to navigate to your Commits

  • Figure 2

  • Copy commit SHA Screenshot of the `Copy commit SHA` button

  • Figure 3

  • Click Comment Screenshot of a comment on the merge request with the commit SHA pasted

  • Figure 4

  • Reply to the comment in the merge request with the commit SHA for the commit in which the comment was addressed. If you addressed the comment with a change to the same line of code, GitLab will automatically include the commit SHA and provide a diff so you can see the changes. Screenshot of checking the `Resolve thread` checkbox and clicking `Add comment now` in a merge request thread

  • Publishing


    Figure 1

    Diagram created with https://learngitbranching.js.org demonstrating the git flow for updating a release candidate branch.
    “Diagram demonstrating the git flow for updating a release candidate branch. Please note that time progresses from top to bottom and arrows point to where the commit originated.”

    Figure 2

    Screenshot of Issue Template for Publishing a Git repository

    Figure 3

    Screenshot of the note that explains a comment was automatically generated

    Figure 4

    Screenshot of creating a new Git tag

    Figure 5

    Screenshot of New Tag page

    Figure 6

    Screenshot of where to click "Create Release"

    Figure 7

    Screenshot of page used to create a Git release

    Figure 8

    Screenshot of deleting a Git branch

    Figure 9

    Screenshot of DOI activation menu

    Continuing Your Project


    Figure 1

    Diagram showing an Upstream and Origin as part of USGS Gitlab, and a Local Clone as part of the the Local Workstation. Arrows go back and forth between Upstream and Origin and between Origin and Local Clone. A dashed line goes between the Local Clone and Upstream.
    Forking Workflow Diagram

    Figure 2

    Screenshot of GitLab UI showing location of fork button

    Figure 3

    Screenshot of GitLab UI for creating a fork

    Figure 4

    Screenshot of GitLab UI for obtaining ORIGIN_URL

    Figure 5

    Screenshot of GitLab UI for creating a new merge request

    Figure 6

    Screenshot of GitLab UI for finalizing new merge request