Tips for git management - JETSCAPE/JETSCAPE GitHub Wiki

The recommended way to develop code and request that it be added to the next JETSCAPE release is to develop your code in a public fork of JETSCAPE, and then make a pull request:

  1. First, fork JETSCAPE via the github interface.
  2. Next, go to the directory on your machine where you would like to develop your local fork of JETSCAPE, and clone JETSCAPE:
    git clone [email protected]:<my_github_username>/JETSCAPE.git
    
  3. Add a remote pointing to the public JETSCAPE repository. This will allow you to keep your fork updated in case there are updates to the JETSCAPE public repository while we are developing our code. Let's also rename your fork's remote to make things clear.
    cd JETSCAPE
    git remote add JETSCAPE [email protected]:JETSCAPE/JETSCAPE.git
    git remote rename origin myFork
    
    You can verify that we now have two "remotes" available that we can pull from and push to:
    git remote -v
    
    [You should see something like the following]
    JETSCAPE    [email protected]:JETSCAPE/JETSCAPE.git (fetch)
    JETSCAPE    [email protected]:JETSCAPE/JETSCAPE.git (push)
    myFork      [email protected]:jdmulligan/JETSCAPE.git (fetch)
    myFork      [email protected]:jdmulligan/JETSCAPE.git (push)
    
  4. Create a new development branch (let’s call it "dev") and add your commits:
    git checkout -b dev           # create a new local branch called "dev"
    ...
    git commit -m "my brilliant commit"
    
  5. Pull in the latest changes from the public JETSCAPE repository, and then push your changes to your fork:
    git checkout main    
    git pull JETSCAPE             # pull in updates from JETSCAPE to your local main branch
    git checkout -b dev               
    git pull --rebase . main      # pull in updates from your local main branch into your local dev branch
                                  # The "rebase" option will keep your commits at the tip of the branch, which keeps an easy-to-manage linear history.
    ...                           
    git push myFork dev:main      # push your local "dev" branch to the "main" branch on your remote fork
    
    In case you are doing long-term developments, you should repeat this step frequently to minimize the chance of merge conflicts.
  6. Open a pull request via the github webpage.

That’s it! You can repeat steps 4-6 for new pull requests.