Set global config

  git config --global user.email "insert_github_email"
  
  git config --global user.name "insert_github_name"

Push existing folder into a git repository
create new blank repository on your git hub page
make sure you have a .gitignore file in your application root directory

cd /into/project/directory

# create initial git monitoring folder
git init

# add all files and folders to git, ignoring items in .gitignore
git add .

# commit changes to git, try to limit a commit to one feature change, 
#   to make roll back easier and your commit messages more descriptive
git commit -m "git commit message"

# set the github repository that will store your files and git history
git remote add origin https://github.com/insert_github_domain_name/insert_github_project_name.git

# set the branch and push the the files to it, if it's an initial 
#   repository upload, typically we're pushing to the default branch, 
#   which is main
git branch -M main

git push -u origin main

Push file changes to an existing project

cd /into/project/directory

git init

# only need to add new files that didn't exist since last commit
git add "insert_new_filename"

git commit -a -m "insert_change_comment"

git push origin main

Push changes to a new branch

cd /into/project/directory

git init

git branch insert_new_branch_name

# connect to new branch
git checkout insert_new_branch_name

git commit -a -m "insert_change_comment"

git push origin insert_branch_name

# how to connect back to default branch
git checkout main

Fork someone's github repository and pull changes
press the fork button on their repository page to add a copy to your github page

cd where/you/want/folder/saved

# download the forked copy of the project
git clone https://github.com/your_github_domain_name/insert_github_project_name.git

cd /into/project

git branch insert_new_branch_name

git checkout insert_new_branch_name

# at this point make changes and save with git add and git commit commands
# push changes to github on your new brnch
git push --set-upstream origin insert_new_branch_name

# if you've worked on the fork for sometime, the original repository 
#   might of changed, so we need to re-sync to make sure your forks 
#   changes won't create a merge conflict
#   below should only list your github urls
git remote -v

# add the original creators repo to upstream so we can compare
git remote add upstream https://github.com/project_owner_domain_name/project_owner_project_name.git

# below should now list their project url too
git remote -v

# grab changes to the project and add to a branch labelled upstream/main 
#   (may be upstream/master, depending on age of project)
git fetch upstream

git checkout main

# this will merge in changes from the upstream/main branch into your 
#   main branch, if there are merge conflicts it will notify you here
git merge upstream/main

make and push any other changes to your new branch, then go to the original projects github page and click on pull request, follow any documentation for completing the pull request before submitting


How to keep a branch up to date with main

cd /to/project/directory

git init

git checkout main

git pull

git checkout insert_branch_name

# merge any modified files from current main branch into your other branch
git merge main

How to update main branch with work from another
once all changes in branch have been committed

cd /to/project/directory

git init

git checkout main

git merge insert_branch_name

git push origin main

Useful commands

# pull any changes on github project repository into local working 
#   directory, critical if multiple people are working on the 
#   same code base
git pull

# list what github repositories are linked to this project folder
git remote -v

# check if any changes or new files haven't been committed to a branch
git status

# adds every new file and folder to be monitored by git
git add -all

# useful for downloading one-off copies of any public git 
#   repositories, if you want to download and make changes you will 
#   have to create a fork
git clone https://github.com/insert_github_domain_name/insert_github_project_name.git