Git with GitHub

Get Started. It's Free
or sign up with your email address
Rocket clouds
Git with GitHub by Mind Map: Git with GitHub

1. Initial Setup

1.1. https://help.github.com/articles/caching-your-github-password-in-git/

1.2. Store your creds

1.2.1. MAC

1.2.1.1. tell git to put your next set of credentials in the OSX keychain

1.2.1.1.1. git config --global credential.helper osxkeychain

1.2.2. PC

1.2.3. Linux/WSL

1.3. create a directory where you'll store your github repository. (You don't have to store them all in the same place, but it makes sense). EG ~/github or C:\github

1.4. setup w Visual Studio Code

1.4.1. Using SSH Keys in Visual Studio Code on Windows · cgranade::space

2. Day-to-Day Work

2.1. Oops! Did you start doing work before creating a new branch?

2.1.1. No prob. create the branch. what matters is what branch you are in when you commit

2.2. create a branch and checkout

2.2.1. git checkout -b <branch>

2.2.1.1. this combines

2.2.1.1.1. git branch <branch>

2.2.1.1.2. git checkout branch

2.3. do work

2.3.1. add changes to git (changed files, new files, new dir)

2.3.1.1. git add <file or parent dir> [<file or dir> <file or dir>...]

2.3.1.1.1. EG

2.3.1.2. this tells git to track these files for changes

2.3.2. show git changes

2.3.2.1. git diff

2.3.2.2. git status

2.3.2.3. git branch

2.3.3. commit work to the branch

2.3.3.1. git commit -m "<change message>"

2.3.3.2. until you do this, you really haven't done any work in the branch

2.3.4. push committed work to github

2.3.4.1. first time pushing this branch?

2.3.4.1.1. git push -u origin <branch>

2.3.4.2. additional pushes

2.3.4.2.1. git push

2.4. First: GitHub GUI

2.4.1. pull request

2.4.2. get approval

2.4.3. merge pull request

2.4.4. delete branch

2.5. Merge to Master & Clean Up

2.5.1. Clean up

2.5.1.1. git status

2.5.1.1.1. should be up-to-date

2.5.1.2. git checkout master

2.5.1.3. git pull

2.5.1.3.1. if you need to pull changes others have made

2.5.1.3.2. git pull origin master

2.5.1.4. git branch -d <old_branch>

3. Get Started

3.1. clone a repo

3.1.1. need to do this before you work w a repo

3.1.2. git clone <url>

3.2. OR, create a new repo

3.2.1. Easiest: Create repo in github & clone

3.2.1.1. Create repo in github

3.2.1.2. clone repo (see above)

3.2.1.3. add files (see Day-to-Day work)

3.2.2. OR, create a new repo from files that exist already

3.2.2.1. gotta fill this in

4. CRAP! I goofed!

4.1. How Do I...

4.1.1. Roll back a pull request

4.1.1.1. This is easy! In the GitHub GUI, go to your pull request, and there is a revert option (or undo or roll back or something like that)

4.1.2. Move a commit to master (that I did not push) to a new branch - or an existing branch? (Yup! I accidentally committed to master!)

4.1.2.1. Move the most recent commit(s) to a new branch with Git

4.1.2.2. more info on undoing a commit: How to With Git: Undo Commit - HostingAdvice.com

5. Pulling from other branches

5.1. Pull latest from master

5.1.1. git merge orgin master

5.2. Pull latest from another branch

5.2.1. git fetch origin other-branch

5.2.2. git merge origin/other-branch

5.2.3. resolve your merge conflicts

5.2.4. git add ... (add your conflict fixes)

5.2.5. git commit ...

5.2.6. Reference

5.3. super article about branching

5.3.1. git: fetch and merge, don’t pull | Mark's Blog

6. Diff

6.1. compare two branches

6.1.1. get the URL of the repo, and add /compare/branch1..branch2

6.1.1.1. EG: https://github.com/Repo/Repo-Sub/compare/master...branch

7. Point to specific code

7.1. use #L

7.1.1. EG url#L48