GitHub Workflow - TREC-Agroecology/lab-wiki GitHub Wiki

Targeted Readings

General Resources

Setting up your repo

  • Example repo Danielcalza/introducing-agroecology

Fork Danielcalza/introducing-agroecology from TREC-Agroecology/introducing-agroecology

Open 'Terminal' or 'Git bash' for Windows (may require install; https://gitforwindows.org/); or 'Terminal' for MacOS.

Navigate to your desired repo location

cd Documents/GitHub_repository

Clone your forked repository

git clone https://github.com/Danielcalza/introducing-agroecology.git

Navigate to your forked repo

cd introducing-agroecology

Set up remote

git remote add upstream https://github.com/TREC-agroecology/introducing-agroecology.git

git remote -v

origin  https://github.com/Danielcalza/introducing-agroecology.git (fetch)
origin  https://github.com/Danielcalza/introducing-agroecology.git (push)
upstream        https://github.com/TREC-agroecology/introducing-agroecology.git (fetch)
upstream        https://github.com/TREC-agroecology/introducing-agroecology.git (push)

Regular workflow

Pull from upstream to local branch master

git pull upstream master
  • NB: Be on branch master for the pull so as not to merge with working branch

Make local branch my-work

git checkout -b my-work

Make local changes, git add <file_name>, git commit -m "<message>"

Push to origin from local branch

git push origin my-work

Create a pull request on GitHub.com

Helpful commands

git status - reports branch and file changes

git log - reports recent commits

git branch - lists branches

git checkout <branch-name> - sets branch in git; changes made to local directory

git branch -d <branch-name> - deletes local branch

git push --delete origin <branch-name> - deletes remote branch

git cherry-pick - selects single commit to recover

⚠️ **GitHub.com Fallback** ⚠️