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:
- Setup
- Download and install GitHub Desktop.
- Log in with your GitHub account.
- Clone a Repository
- Click on
File
>Clone Repository
from the main menu. - Select a repository from the list or enter a repository URL.
- Make Changes
- Edit files in your preferred text editor.
- Commit Changes
- Return to GitHub Desktop. It will show changed files.
- Enter a commit message and description.
- Click
Commit to master
(or your current branch). - Push Changes
- Click the
Push Origin
button at the top. - Syncing
- 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:
- Setup
- Install Visual Studio Code.
- Install the Git extension if it isn't already.
- Clone a Repository
- Press
Ctrl+Shift+P
(orCmd+Shift+P
on Mac). - Type
Git: Clone
and paste the repository URL. - Make Changes
- Edit files directly within VS Code.
- Commit Changes
- Click on the source control icon on the sidebar.
- Enter a commit message.
- Press the checkmark at the top.
- Push Changes
- Click on the ellipsis (
...
) >Push
. - Syncing
- 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:
- Setup
- Install Git.
- Clone a Repository
git clone [repository-url]
.- Make Changes
- Use your preferred text editor to make changes.
- Commit Changes
git add .
git commit -m "Your commit message here"
.- Push Changes
git push origin master
(or your current branch).- Syncing
git pull
to pull changes from GitHub.
b. GitHub CLI:
Here is how to get code to GitHub using GitHub CLI:
- Setup
- Install GitHub CLI.
- Authenticate using
gh auth login
. - Clone a Repository
gh repo clone [repository-url or owner/repo]
.- Make Changes
- Edit files with your preferred text editor.
- Commit Changes
git add .
git commit -m "Commit message"
.- Push Changes
git push origin master
(or your current branch).- Open Pull Requests, Issues, etc.
- Use various
gh
commands likegh pr create
orgh 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.