Skip to content

Latest commit

 

History

History
68 lines (38 loc) · 1.64 KB

git-cheatsheet.md

File metadata and controls

68 lines (38 loc) · 1.64 KB

Working with Git Repos


Initial Local Repository Setup (Done Once)


  1. Using git bash, navigate to the location you wish to create your repo. This can be done using:

    cd path\to\folder\

  2. Set up a new local repository from something exisiting on GitHub:

    git clone <URL>

    The URL is copied from the GitHub repo you are wishing to create.


General Pull Request Workflow (repeat 4-6 as needed)


  1. Create a new branch. You will typically always want to do this, try to never work directly on the main branch.

    git checkout -b <branchname>

  2. Make your changes as needed to the code.

  3. Commit all changes to branch:

    git add <filenames>

    git commit -m "Descriptive comment of what I changed/updated"

  4. Push branch with changes back to the remote (origin):

    git push -u origin <branchname>

    or for subsequent changes to the pull request, setting up the origin to track this branch is not neccessary:

    git push

  5. On GitHub:

    Click Compare & Pull Request

    Request a reviewer (someone else on the team)

    Reviewer:

    • request changes or approve.

    • in order to look at someone elses pull request on your local machine (to test the code, make sure it runs smoothly, view notebook changes, etc.), run:

      git checkout <pull-request-branch-name>

    Once approved: Original author merges into the main branch and deletes the extra branch.


Tidying Up An Approved Pull Request


  1. Get local repo back up-to-date on the main branch:

    git checkout main

    git pull

  2. Delete the old local branch you were working on:

    git branch -d <branchname>