Git work flow E3SM

1) Fork a branch to my own repo on Github

2) Clone a branch from my own repository with submodules

$ git --recursive -b branch/name/here https://username:password@github.com/hydrotian/ACME.git

3) Make changes to the code, add them,and commit

$ git add --all
$ git commit –a -m "comments to this commit"

4) Push changes to my repo

$git push origin name/of/the/branch:name/of/the/branch

5) Send pull request on Github

Additional commands

check submodule list

$ git submodule

if there are submodules, clone the submodules by

$ git submodule init
$ git submodule update

 

check remote and branch

$ git remote 
$ git branch -v

Add aliases

This following command create a “git hist” aliases based on “git log” to visually check the commit history

git config --global alias.hist "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short"

Go back to old commits

find the hash of the target commit by checking the commit history, then

git checkout    # something like "git checkout 911e8c9"

Add ssh key to Github to avoid input password

  • Type cd ~/.ssh.
  • Within the .ssh folder, there should be these two files: id_rsa and id_rsa.pub. If not, create them by typing
 ssh-keygen -t rsa -C "your_email@example.com"
  • Open id_rsa.pub, copy everything and paste it into GitHub and/or BitBucket under the Account Settings, SSH Keys