Skip to content

Set Up Git

Create Account

Create a free GitHub account at github.com, choosing a unique username and providing your email. Opt for the free plan for unlimited public repositories (and private repositories too). Click the top-right profile picture to personalize your profile.

To join the SWAT-Model Research Group on GitHub, reach out to: Celray James: Profile , Jaclyn: Profile , Christoph: Profile

For a primer on GitHub, see the 'GitHub Hello World Guide'.

In the next section, we'll discuss using Git for code management. Git allows for changes to local repositories and then pushes to GitHub. An SSH key is essential for a secure connection between your device and GitHub but it is not mandatory.

Get your code to a repo

You can create your repository on Github web or publish one from any of the methods we will discuss soon.

There are different ways to get your code to Github but in this guide, we briefly mention a few. For more detailed instructions please visit documentation for each of the software mentioned.

1. GitHub Desktop

This is the easiest method and is recommended for beginners.

Here is how to get code to GitHub using GitHub Desktop:

  1. Setup
  2. Download and install GitHub Desktop.
  3. Log in with your GitHub account.
  4. Clone a Repository
  5. Click on File > Clone Repository from the main menu.
  6. Select a repository from the list or enter a repository URL.
  7. Make Changes
  8. Edit files in your preferred text editor.
  9. Commit Changes
  10. Return to GitHub Desktop. It will show changed files.
  11. Enter a commit message and description.
  12. Click Commit to master (or your current branch).
  13. Push Changes
  14. Click the Push Origin button at the top.
  15. Syncing
  16. To pull changes from GitHub, click the Fetch origin button.

2. Visual Studio Code

This is moderately easy. Here is how to get code to GitHub using Visual Studio Code:

  1. Setup
  2. Install Visual Studio Code.
  3. Install the Git extension if it isn't already.
  4. Clone a Repository
  5. Press Ctrl+Shift+P (or Cmd+Shift+P on Mac).
  6. Type Git: Clone and paste the repository URL.
  7. Make Changes
  8. Edit files directly within VS Code.
  9. Commit Changes
  10. Click on the source control icon on the sidebar.
  11. Enter a commit message.
  12. Press the checkmark at the top.
  13. Push Changes
  14. Click on the ellipsis (...) > Push.
  15. Syncing
  16. Click the sync icon at the bottom left to fetch and integrate changes.

3. Command Line

a. Git CLI:

Here is how to get code to GitHub using Git CLI:

  1. Setup
  2. Install Git.
  3. Clone a Repository
  4. git clone [repository-url].
  5. Make Changes
  6. Use your preferred text editor to make changes.
  7. Commit Changes
  8. git add .
  9. git commit -m "Your commit message here".
  10. Push Changes
  11. git push origin master (or your current branch).
  12. Syncing
  13. git pull to pull changes from GitHub.

b. GitHub CLI:

Here is how to get code to GitHub using GitHub CLI:

  1. Setup
  2. Install GitHub CLI.
  3. Authenticate using gh auth login.
  4. Clone a Repository
  5. gh repo clone [repository-url or owner/repo].
  6. Make Changes
  7. Edit files with your preferred text editor.
  8. Commit Changes
  9. git add .
  10. git commit -m "Commit message".
  11. Push Changes
  12. git push origin master (or your current branch).
  13. Open Pull Requests, Issues, etc.
  14. Use various gh commands like gh pr create or gh issue create.

Remember, the best method often aligns with your comfort level and the tasks you're trying to accomplish. Starting with GitHub Desktop and progressing to the command line as you become more comfortable can be a great way to gradually build your Git and GitHub skills.