| layout | title | permalink |
|---|---|---|
default |
GitHub Setup |
/github-setup/ |
This section walks through creating a GitHub account, installing Git locally, and configuring SSH access so you can push/pull repositories securely without repeatedly entering your password.
- Go to GitHub.
- Click Sign up.
- Follow the prompts to create your account (email, username, password).
- Verify your email address when prompted.
- Enable two-factor authentication (2FA) in Settings → Password and authentication.
Choose the instructions for your system.
In a terminal window, run the following command:
sudo apt update
sudo apt install git
git --versionMost versions of macOS already have Git installed. Open a terminal window and check to see if Git is already activated. If Git is not installed, you can install the latest version from GitHub.
If you have Homebrew already installed, you can use the following command:
brew install git
git --versionInstall Git for Windows from https://git-scm.com/install/.
During installation, keep the default options unless you have a reason to change them.
Open Git Bash and verify:
git --versionSSH keys let you authenticate with GitHub securely. More details here: https://docs.github.com/en/authentication/connecting-to-github-with-ssh
Enter the following terminal window, replacing the email address in quotes with the email associated with your GitHub account:
ssh-keygen -t ed25519 -C "your_email@example.com"Press Enter without entering anything to accept the default file location.
Enter a passphrase if you want extra security (recommended). If you do not want a password, press Enter to continue without entering anything.
Enter the following in the same terminal window:
cat ~/.ssh/id_ed25519.pubCopy the entire output (starting with ssh-ed25519).
- Go to GitHub → Settings.
- Click SSH and GPG keys.
- Click New SSH key.
- Paste your public key into the key field.
- Enter a descriptive title (e.g.,
laptop,desktop,cluster). - Click Add SSH key.
Enter the following in the same terminal window:
ssh -T git@github.comYou should see a message indicating that authentication succeeded.
When running G&R simulations, you often need to build on existing code. This guide follows the typical workflow: finding a repository on GitHub, forking it to your account, creating a space on your local machine to experiment with code, and securely pushing your changes back to a new branch on your fork that is accessible by others who want to use your code.
Find the repository of the code you want to use. Hit the "Fork" button on the original GitHub repository to create a copy under your own account. Then, clone the repository to your local machine.
- Clone your forked repository locally:
In a terminal window, enter the following, replacing [url] with the link to the GitHub repository (e.g., git@github.com:febiosoftware/FEBio.git).
git clone [url]To ensure your experiments don't break the original stable code, you should create a dedicated development branch locally.
- List all existing branches:
git branch- Create a new development branch:
Replace [branch-name] with the name you want to use for your branch.
git branch [branch-name]- Switch to your new branch:
git checkout [branch-name]On your local machine, edit the code until you are happy with your workflow. Then, tell Git which files you want it to track and update (stage).
- Check the status of your files: (Shows modified files in your working directory and what is staged for your next commit.)
git status- Stage a specific file:
Replace [file] with the file name(s) you want to update.
git add [file]- Or, stage ALL your current changes:
git add .- Commit your staged changes to your local history: (Leave a clear note for yourself and future collaborators summarizing what changes you made in plain language.)
Replace [message] with your note.
git commit -m "[message]"So far, your changes are only on your local machine. Now, you need to push them up to your new branch on GitHub so other people can see and build on them.
- Link a remote repository:
(If you need to define where your code is going, or want to link back to the original source you forked from, your default
aliasisorigin.)
Replace [url] with the link to the remote repository (e.g., git@github.com:febiosoftware/FEBio.git).
git remote add [alias] [url]- Push your local branch up to your GitHub account:
git push [alias] [branch-name]If collaborators have updated the code, or you want to sync your local branch with remote updates (what's on your GitHub account):
- Fetch and merge remote changes into your local workspace:
git pull