Skip to content

Setup your Github on the SMCE

Colin edited this page Oct 27, 2025 · 8 revisions

Useful tips to run git smoothly on the SMCE:

Authenticating your GitHub account: Access Tokens

Github access tokens enable you to authenticate with Github from a local coding environment without needing to provide your username and password for each github related action (e.g., pushing commits to Github).

There are various ways you can authenticate and develop github code and security access on the SMCE, but one suggested approach is:

  1. Create a fine-grained token for use with the github CLI
  • Visit the PAT section of your github account
  • Select your profile thumbnail > "Settings" > scroll on the left hand side to "< > Developer Settings"
  • Expand Personal access tokens on the left hand side and select "Fine-grained tokens"
  • "Generate new token"
    • name your token, set expiration date
    • the easiest method (among many) is to select "Only select repositories" under "Repository access" and add the repos you want to access on the SMCE
    • for now, once you have added at least one repository, click the "+ Add permissions" under the Permissions header, scroll down and select "Contents" and change the "Access: Read-only" option to "Read and write". This will enable push/pull functionality. If you would like to expand permissions in the future, you can update them here.
      NOTE: before clicking generate token make sure you are ready to use the token at the SMCE command line by following steps 2-5 below.
  1. Create a new hidden directory on the SMCE that will contain your token(s)
mkdir -p ~/.github_tokens
  1. And then make a new file that contains your new token, e.g.
touch ~/.github_tokens/airborne_smce_general.txt
  1. Paste your new token into this file and save the file

  2. Run gh auth to register your credentials and run through the prompts on the command line, e.g.:

gh auth login --with-token < ~/.github_tokens/airborne_smce_general.txt
? Where do you use GitHub? GitHub.com
? What is your preferred protocol for Git operations on this host? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Login with a web browser
  1. Try git cloning a GitHub repo to a directory on the SMCE, e.g.:
gh repo clone GSFC-618/airborne-smce-environments

Additional documentation:


Setting up Global Git Variables

  1. Setup your global environment variables

Your github username, e.g.

git config --global user.name "John Doe"

Your email, e.g.

git config --global user.email johndoe@example.com
  1. Review your settings
git config --list

e.g.

sserbin@jupyter-sserbin:~/Github$ git config --list
sserbin@jupyter-sserbin:~/Github$ user.name=serbinsh
sserbin@jupyter-sserbin:~/Github$ user.email=shawn.p.serbin@nasa.gov

How to add work to a GitHub repo:

An example to begin working on GSFC 618 GitHub repositories on SMCE including cloning a GitHub repo, adding a file with text, committing, branching, and pushing to the GitHub repo:

  1. Clone this GitHub repository
user@jupyter-user:~$ gh repo clone GSFC-618/airborne-smce-environments
user@jupyter-user:~$ cd airborne-smce-environments
user@jupyter-user:~$ git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
  1. Branch, add a file, commit.
user@jupyter-user:~$ git checkout -b example
Switched to a new branch 'example'
user@jupyter-user:~$ git branch -a
  main
* example
  remotes/origin/HEAD -> origin/main
  remotes/origin/main
user@jupyter-user:~$ touch example.txt
user@jupyter-user:~$ echo "Welcome to the airborne SMCE" > example.txt 
user@jupyter-user:~$ git status
On branch example
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        example.txt

nothing added to commit but untracked files present (use "git add" to track)
user@jupyter-user:~$ git add example.txt
user@jupyter-user:~$ git commit -m "First example commit message"
[example 7cdc9cf] First example commit message
 1 file changed, 1 insertion(+)
 create mode 100644 example.txt

Now you have successfully added your own work to a local git repo - it is not connected to GitHub at this point. You can alternatively stash your changes instead of committing if needed. Notes:

  • git checkout -b <branch_name> both creates a new branch and moves you to that branch.
  • Use git checkout <branch_name> after that branch exists
  1. Ensuring your example branch is up to date with main:
user@jupyter-user:~$ git checkout main
user@jupyter-user:~$ git pull origin main
user@jupyter-user:~$ git checkout example
user@jupyter-user:~$ git merge main

At this point your working branch example has 1) your committed work and 2) is up to date with the Github version of main.

  1. Push to GitHub
user@jupyter-user:~$ git push origin example
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Delta compression using up to 4 threads
Compressing objects: 100% (1/1), done.
Writing objects: 100% (1/1), 344 bytes | 57.00 KiB/s, done.
Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
remote: 
remote: Create a pull request for 'example' on GitHub by visiting:
remote:      https://github.com/GSFC-618/airborne-smce-environments/pull/new/example
remote: 
To https://github.com/GSFC-618/airborne-smce-environments.git
 * [new branch]      example -> example
  1. Now your local branch is available online at GitHub. At this point you can follow the supplied pull request link to move your work into main if your update is complete. It will be reviewed by another developer and may even need to pass certain deployment tests to successfully merge into main.

Additional documentation:
https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration