Memo

Page content

SSH

# 1. Generate key with -t ed25519 or -t rsa -b 4096
ssh-keygen -t ed25519 -C "[email protected]"

# 2. Add the key to the ssh-agent
eval "$(ssh-agent -s)"
   
# -K is only needed for Mac OS
ssh-add -K ~/.ssh/mykey
# or
ssh-add --apple-use-keychain ~/.ssh/mykey

# 3. Add SSH key to the remote server
ssh-copy-id -i ~/.ssh/mykey user@remote

# 4. Connnect remote with the key
ssh -i ~/.ssh/mykey user@remote

multiple Github accounts

for ~/.ssh/config, set

Host private
HostName ssh.github.com
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile <key_1>

Host work
HostName ssh.github.com
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile <key_2>

Discover settings

# nccs
Host discover.nccs.nasa.gov discover-nastran.nccs.nasa.gov dirac.nccs.nasa.gov dataportal.nccs.nasa.gov adapt.nccs.nasa.gov discover-mil.nccs.nasa.gov
User <user_name>
LogLevel Quiet
ProxyCommand ssh -l <user_name> login.nccs.nasa.gov direct %h
Protocol 2
ForwardAgent yes
ForwardX11   yes

Git

# set default editor
git config --global core.editor "vim"

# customized clone
git clone -o <newname_of_remote> <git_repo_url> <local_dir>

Get remote branch other than ‘main’

git fetch <remote_name>
git branch -v -a
git checkout -b <local_branch_name> <remote_name>/<remote_branch_name>

Avoid message of merge branch

git pull --rebase <remote_name> <remote_branch_name>

Undo the last merge

git reset --hard HEAD~1

Change Author/Email for the last commit

git commit --amend --author="First Last <user@email>"

Change Author/Email for the last several commits

git rebase -i HEAD~N
#choose e for comits

#loop these two
git commit --amend --author="First Last <user@email>" --no-edit
git rebase --continue

Git: submodule

Create a submodule

  1. Add the repo inside the current git directory
    git submodule add [remote_submodule_repo_url]
    
  2. Then .gitmodules will be created.
  3. git add .gitmodules and git commit
  4. (optional) git push origin main

Clone repo w/ source codes of submodules

If you want to clone the git with all the source files inside submodules, you can use

git clone --recurse-submodules [remote_main_repo_url]

Clone repo w/o source codes of submodules

If you only want to clone the main repo without the source files inside the submodule you can use

git clone [remote_main_repo_url]

And the repo inside the submodules will be empty.

If you now want to get the source codes of all submodules, run

git submodule init
git submodule update

Clone specific submodules

git clone [remote_main_repo_url]
git submodule init [submodule_name]
git submodule update [submodule_name]

Update the commit of submodules

The submodules included in the main repo will stay at the commit when you use git submodule add. To update the submodules to the latest commit inside the main repo, do this

cd submodule_dir
git fetch
git checkout main
git merge origin/main
cd ..                            # go back to top repo
git status                       # should show that the submodule dir changes
git add submodule_dir
git commit -m "Update submodule" # you should see on github now submodule at different commit

Vim

~/.vimrc

let fortran_free_source=1
syntax on
set t_Co=256
"set background=light
"set background=dark
"colorscheme solarized

set nu
set ruler
syntax on
set hlsearch
hi Search ctermbg=red
hi Search ctermfg=white
set autoindent
set smartindent
"set cindent
set tabstop=4
set shiftwidth=4
set expandtab

syntax enable

force syntax

:set syntax=Fortran