Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
/afs/slac/g/cd/swe/git/repos/slac/FACET/matlab2020amatlabTNG.git

The production version (on facet-srv0X) is here:

Code Block
/usr/local/facet/tools/matlab2020a//matlabTNG/

The repository is also mirrored on github here: https://github.com/slaclab/facet-matlabTNG

Cloning the repo on AFS (rhel6-64, lcls-dev3, et al)

...

Code Block
[sgess@rhel6-64a ~/sgess/git_work ]$ git clone /afs/slac/g/cd/swe/git/repos/slac/FACET/matlab2020amatlabTNG.git 
Initialized empty Git repository in /u/at/sgess/git_work/matlab2020amatlabTNG/.git/
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
[sgess@rhel6-64a ~/sgess/git_work ]$ ls
matlab2020amatlabTNG


Cloning the repo on facet-srv0X

...

Code Block
[fphysics@facet-srv01 ~/sgess/git_work ]$ git clone ssh:///afs/slac/g/cd/swe/git/repos/slac/FACET/matlab2020amatlabTNG.git 
Initialized empty Git repository in /home/fphysics/sgess/git_work/matlab2020amatlabTNG/.git/
sgess@mcclogin's password: 
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
[fphysics@facet-srv01 ~/sgess/git_work ]$ ls
matlab2020amatlabTNG


Editing a file and pushing the changes

...

Code Block
[sgess@rhel6-64a ~/sgess/git_work/matlab2020amatlabTNG ]$ vim README.md 
[sgess@rhel6-64a ~/sgess/git_work/matlab2020amatlabTNG ]$ git commit -m "test commit from AFS" README.md 
[master c2cb0c2] test commit from AFS
 1 files changed, 2 insertions(+), 0 deletions(-)
[sgess@rhel6-64a ~/sgess/git_work/matlab2020a ]$ git push origin master
Counting objects: 5, done.
Delta compression using up to 40 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 333 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To /afs/slac/g/cd/swe/git/repos/slac/FACET/matlab2020amatlabTNG.git
   ffd224e..c2cb0c2  master -> master

...

Code Block
[fphysics@facet-srv01 ~/sgess/git_work/matlab2020amatlabTNG ]$ vim README.md 
[fphysics@facet-srv01 ~/sgess/git_work/matlab2020amatlabTNG ]$ git commit -m "test commit from facet-srv01" README.md 
[master c2cb0c2] test commit from facet-srv01
 1 files changed, 2 insertions(+), 0 deletions(-)
[fphysics@facet-srv01 ~/sgess/git_work/matlab2020amatlabTNG ]$ git push origin master
sgess@mcclogin's password: 
Counting objects: 5, done.
Delta compression using up to 40 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 333 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh:///afs/slac/g/cd/swe/git/repos/slac/FACET/matlab2020amatlabTNG.git
   ffd224e..c2cb0c2  master -> master

...

Code Block
[fphysics@facet-srv01 ~/sgess/git_work/matlab2020a ]$ cd /usr/local/facet/tools/matlab2020amatlabTNG/
[fphysics@facet-srv01 /usr/local/facet/tools/matlab2020amatlabTNG ]$ git pull
sgess@mcclogin's password: 
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From ssh:///afs/slac/g/cd/swe/git/repos/slac/FACET/matlab2020amatlabTNG
   c2cb0c2..4cb81f7  master     -> origin/master
Updating c2cb0c2..4cb81f7
Fast-forward
 README.md |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-

...

  • General Git workflow to push changes to central repo: add, commit, fetch*, pull, push 
    *git fetch is optional, but recommended in the event of multiple developers working in the same repo. Via StackOverflow:

    git fetch updates your local copy of the repository but does not modify any files in the working directory. It simply makes sure that the cached info it has about the repository you fetched is up-to-date. (If other people created new branches or added some commits since the last time you fetched, git will learn about them.)

    git pull is shorthand for git fetch followed by git merge FETCH_HEAD. That is, it runs git fetch and then merges the changes from the remote repository into your current branch and working directory.

    Code Block
    [sgess@rhel6-64a ~/sgess/git_work/matlab2020amatlabTNG ]$ vim README.md
    [sgess@rhel6-64a ~/sgess/git_work/matlab2020amatlabTNG ]$ git add README.md
    [sgess@rhel6-64a ~/sgess/git_work/matlab2020amatlabTNG ]$ git commit -m "example of typical git workflow"
    [sgess@rhel6-64a ~/sgess/git_work/matlab2020amatlabTNG ]$ git fetch origin
    [sgess@rhel6-64a ~/sgess/git_work/matlab2020amatlabTNG ]$ git pull origin master
    [sgess@rhel6-64a ~/sgess/git_work/matlab2020amatlabTNG ]$ git push origin master
  • It is good practice to specify the remote repo and branch (e.g., git push/pull origin master), particularly in case there are multiple branches in a repo.
  • Leaving helpful descriptions of changes, bug fixes, etc. is strongly encouraged in your commit messages.
  • When releasing a new repo to the production release area, the remote repo should be specified with the `ssh://` protocol. This will ensure that other FACET-II shared account users (fsoftegr/fphysics) will be able to access the repo and make changes. E.g.:

    Code Block
    [fphysics@facet-srv01 /usr/local/facet/tools/matlab2020amatlabTNG ]$ git clone ssh:///afs/slac/g/cd/swe/git/repos/slac/FACET/matlab2020amatlabTNG/my_new_repo.git
    [fphysics@facet-srv01 /usr/local/facet/tools/matlab2020amatlabTNG ]$ cd my_new_repo && git remote -v
    origin	ssh:///afs/slac/g/cd/swe/git/repos/slac/FACET/matlab2020amatlabTNG/my_new_repo.git (fetch)
    origin	ssh:///afs/slac/g/cd/swe/git/repos/slac/FACET/matlab2020amatlabTNG/my_new_repo.git (push)
  • You may work with repos hosted in cloud services such as GitHub/GitLab/etc, but when deploying code to production you must sync them to the master AFS repos as indicated above. This is typically done as follows:

    1. Sync to local AFS workspace via internet accessible node (rhel6-64, lcls-dev3).
    2. Push to AFS master repo (this can be done by setting different remote repos for fetching and pushing).
    3. Proceed with releasing software to production as indicated above.

...