Day 3 On your own:#

Sharing your changes with others & pushing changes back to your GitHub Repository#

Note: If you plan to contribute your code developments to CTSM or the CTSM-Tutorial, you will need to use these optional steps to share your code with CTSM model developers. If you already have a GitHub account and have a CTSM fork, start at step 2.

So far, we made a code change and saved it to a local branch. In reality, we usually want/need to push our changes back to GitHub so our collaborators can see, comment, or use our code modifications. Imagine saving your progress in a video game or in a Word document on a local computer. If you use a different computer, you can not load your progress. However, if you save your video game progress or your Word document on the cloud, you can easily access it from any computer. Nowadays, video games save your progress via a profile/account and Word documents can be saved and shared through Google or Dropbox accounts.

Similarly, you need to create an account on GitHub to be able to share your changes so:

  • you can access your code and changes from anywhere.

  • you can share with collaborators.

  • you can contribute back to CTSM tutorial repository.

1. Create a GitHub account#

Visit the GitHub website and create an account if you don’t already one. You can skip step this if you already have a GitHub account.

2. Create a fork from CTSM-Tutorial-2022 repository#

You don’t have access to write directly to the main CTSM tutorial repository (that right is reserved for the tutorial developers), so you need to create your own copy of the repository to save your changes. For this, you will fork the CTSM tutorial repository.

NOTE: A fork is a copy of a repository. "Fork"ing a repository is similar to creating a branch in that it allows you to freely experiment with changes without affecting the original project. However, we recommend using your CTSM fork as an unmodified copy of CTSM tutorial repository and making changes using branches.

To Do: Create a fork#

You can create your own fork of the CTSM tutorial repository by using the fork button in the upper right corner of the CTSM tutorial reository page.

  • Login to your GitHub account.

  • Navigate to the original CTSM tutorial repository.

  • Use the fork button to create a fork of CTSM repository in your account NOTE: The image below is from the CTSM repository, but the GitHub interface looks the same for the tutorial repository.

image3.png

Your forked repository will be under your account name:

https://github.com/YOUR-USER-NAME/CTSM-Tutorial-2022

For example, for the username (wwieder) the forked repo is:

https://github.com/wwieder/CTSM-Tutorial-2022

You can make any modifications you’d like to your forked repository. Note that you only have to fork a respository once – it will always be connected to your GitHub account unless you delete it.

3. Pushing your changes to the outside world:#

To start, connect your forked repository to the computing system you are using. You can do so by using the following:

WARNING!

Please replace “YOUR_USER_NAME” in the code below with your own GitHub username (created in step 1).

git remote add YOUR_USER_NAME https://github.com:YOUR_USER_NAME/CTSM-Tutorial-2022.git

Finally, push your changes to the remote repository. Note that ‘pushing’ the changes makes the changes visible to anyone who looks at your GitHub repository, including your collaborators.

git add -a
git commit -m 'all my notebook changes'
git push YOUR_USER_NAME 

To see your changes now you can go to your fork and look for your ‘main’ branch on github.com. You should be able to see your recent changes.