Skip to content

Roger-Takeshita/GitHub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

VSCODE SHORTCUTS

Preview Markdown Mac

Go Back to Summary

  • CMD+Shift+V: open README Preview in VSCode

Preview Markdown Windows

Go Back to Summary

  • Ctrl+Alt+V: open README Preview in VSCode

SET VSCODE AS DEFAULT EDITOR

Default Editor - MAC

Go Back to Summary

  • If you manually install Visual Studio Code, rather than using Homebrew, you will need to add the code executable to your PATH.

    brew cask install visual-studio-code
  • In terminal

    1. Type: open ~/.bash_profile
    2. Delete everything and insert: export EDITOR="code -w"
  • In visual studio code

    1. Press: CMD + SHIFT + P
    2. Insert: install code and select from autocomplete menu shell command: Install 'code' in command PATH

WORKFLOW

Go Back to Contents

  • GitHub Workflow

    • The idea is to have the following branches

      • production, real production workload (live code)
        • hotfixes, branches that are quick fixes on production
      • stating (release branches), blue / green server, duplicate of the production environment (testing)
        • If all tests pass, we will swap it with production
      • main (development), where we are going to merge all features
        • features
        • qa, perform tests before merging into staging

Branches

Go Back to Contents

  • On Terminal, create remote branches

    git checkout -b production
    git push
    git push --set-upstream origin production
    
    git checkout -b hotfixes
    git push
    git push --set-upstream origin hotfixes
    
    git checkout -b staging
    git push
    git push --set-upstream origin staging
    
    git checkout -b main
    git push
    git push --set-upstream origin main

Issue Label

Go Back to Contents

  • On your repo

    • Click on Issues tab

    • Click on New issue

      • On the sidebar, click on Labels > Edit labels

        • Add the following labels

          • feature
          • hotfix
          • maintenance

New Ticket

Go Back to Contents

  • On repo > Issues Tab > New issue

    • Create a new issue:

      • Title: Update README file

      • Description: I need to add GitHub workflow.

      • Sidebar:

        • Assignees: Roger-Takeshita (in this case we are assigning to ourselves)
        • Labels: feature
      • Click on Submit new issue

  • After creating a new issue, it will generate a issue number (ticket number, in this case #1)

    • We create the issue first so we can get the ticket number and correlate the ticket to the branch that we are currently working on

    • In this case we don't have anything yet, but we will create a new branch (feature/ticket-number-branch-name)

Add New Feature

Go Back to Contents

  1. New Ticket

    • On GitHub > Issues
      • Click on New Issue
        • Title: Update README file
        • Description: I need to add GitHub workflow.
        • Sidebar:
          • Assignees: Roger-Takeshita
          • Labels: feature
        • Click on Submit new issue
  2. Feature Branch

    • Create new feature branch (feature/ticket-number-branch-name)

    • On Terminal:

       # From the main branch
       git checkout main
       # Create a new feature branch
       git checkout -b feature/1-update-readme-github-workflow
       # update README
       git add README.md
       git commit -m "#1 - should add github workflow"
       # Your commit message should follow
       # #1 -> Ticket number (don't forget the #)
       # -   -> optional
       # msg
       git push
       git push --set-upstream origin feature/1-update-readme-github-workflow
  3. Main Branch

    • Create a new Pull Request (main <- feature)

    • On GitHub > Pull requests

      • Click on New pull request
        • Compare Changes
          • base: main <- compare: feature/1-update-readme-github-workflow
          • Click on Create pull request
            • Description: I've updated README file with github workflow
            • Click on Create pull request
  4. Staging Branch

    • After someone merge your PR into the main branch, we need to send to staging branch

    • On Terminal

       # Update the main branch with the merged modifications
       git checkout main
       git pull
      
       # Change to staging branch
       git checkout staging
       git merge main
       git tag "v1.0.0"
       #         ^ ^ ^
       #         | | └── Hotfixes
       #         | └── Feature/Minor updates
       #         └── Major updates
       git push --tags
    • Create a new Pull Request (staging <- main)

    • On GitHub > Pull requests

      • Click on New pull request
        • Compare Changes
          • base: staging <- compare: main
          • Click on Create pull request
            • Title: Latest README update - Add GitHub Workflow
            • Description: Added GitHub workflow
            • Click on Create pull request
  5. Production Branch

    • Create a new Pull Request (production <- staging)

    • On GitHub > Pull requests

      • Click on New pull request
        • Compare Changes
          • base: production <- compare: staging
          • Click on Create pull request
            • Title: Staging to Production - Add GitHub Workflow
            • Description: Adding GitHub Workflow into production
            • Click on Create pull request

Hotfix

Go Back to Contents

  1. New Ticket

    • On GitHub > Issues
      • Click on New Issue
        • Title: Update README file immediately add hotfix
        • Description: I forgot to add hotfix doc
        • Sidebar:
          • Assignees: Roger-Takeshita
          • Labels: hotfix
        • Click on Submit new issue
  2. Hotfix Branch

    • Create new bug branch (hotfixes)

    • On Terminal:

       git checkout main
       git pull
       # From the production branch
       git checkout hotfixes
       git merge production
       # update README
       git add README.md
       git commit -m "#5 - should add hotfix doc"
       # Your commit message should follow
       # #5 -> Ticket number (don't forget the #)
       # -   -> optional
       # msg
       git push
       git tag "v1.0.1"
       #         ^ ^ ^
       #         | | └── Hotfixes
       #         | └── Feature/Minor updates
       #         └── Major updates
       git push --tags
  3. Production Branch

    • Create a new Pull Request (production <- hotfixes)

    • On GitHub > Pull requests

      • Click on New pull request
        • Compare Changes
          • base: production <- compare: hotfixes
          • Click on Create pull request
            • Title: Updated readme with hotfix doc
            • Description: Updated readme with hotfix documentation
            • Click on Create pull request

COMMANDS

REMOTE

Go Back to Summary

git remote set-url origin <url>

Set New Remote Upstream

Go Back to Summary

git remote add upstream <url>

Check Remote/Upstream URL

Go Back to Summary

git remote -v

Set Different Repos Into a Single Repo

Go Back to Summary

  • It often happens that while working on one project, you need to use another project from within it. Perhaps it’s a library that a third party developed or that you’re developing separately and using in multiple parent projects. A common issue arises in these scenarios: you want to be able to treat the two projects as separate yet still be able to use one from within the other.

  • More information how to clone a project with submodules Official Docs

    git submodule add <repo_url>

Prevent Pushing To Master

Go Back to Summary

  • Disable git from pushing to origin

    git remote set-url --push origin no_push

UPSTREAM

Add Upstream

Go Back to Summary

git remote add upstream https://github.com/Roger-Takeshita/GitHub.git

Fetch Latest From Upstream

Go Back to Summary

git fetch upstream

Merge/Rebase Upstream

Go Back to Summary

git merge upstream/master master

# or

git rebase upstream/master

FETCH/PULL MODIFICATIONS

Check All Modifications from Remote (Origin)

Go Back to Summary

  • Fetch all the remote files that have been changed (just the paths)

  • It doesn't download the modifications

    git fetch

Download All Modifications from Remote (Origin/Branch)

Go Back to Summary

  • Pull all the modified files

    git pull origin master/branch

Download All Modifications from Upstream

Go Back to Summary

  • Download all modifications from upstream (a forked repo) to your local machine (master)

    git pull upstream master

MERGE CONFLICT

Undo a Merge

Go Back to Summary

  • Sometimes we pull the modifications from origin/upstream but we change our mind, and we don't want to merge the modifications on our master branch. But we already pulled.

  • This will return to the state before we started the merge at any time.

    git merge --abort

Check for Leftover Conflicts

Go Back to Summary

  • List all the file names that have conflicts + the line and highlight as a conflict

    git diff --check | grep -i conflict
    d2bs/kolbot/tools/ToolsThread.js:786: leftover conflict marker
    d2bs/kolbot/tools/ToolsThread.js:788: leftover conflict marker
    d2bs/kolbot/tools/ToolsThread.js:791: leftover conflict marker

Check for Leftover Conflicts - Only File Names

Go Back to Summary

  • List all the file names that have conflicts

    git ls-files -u | cut -f 2 | sort -u
    d2bs/kolbot/tools/ToolsThread.js

LOGS

Log Commits (One Line)

Go Back to Summary

  • List all commits in one line, useful to get hash keys

    git log --oneline

Log Commits Message Only

Go Back to Summary

git log -n --pretty=format:%s $hash
  • Option 1) If you want to view the last message, you can just add the -n = number of past commit(s), whitout $hash. Example:

    git log -1 --pretty=format:%s
  • Option 2) IF you want to view a specific commit, you use -n = 1 and $hash = hash key

    git log -n 1--pretty=format:%s a63ef55
    • a63ef55 is the hash key

STASH

Stash Uncommitted Files/Changes

Go Back to Summary

  • To stash all the changes without the need to commit/push

    git stash save "Your Message Here"
    
    git stash save "first stashed files"
    # Saved working directory and index state On master: first stashed files
    
    git stash list
    # stash@{0}: On master: first stashed files
    
    git stash save "second stashed files"
    # Saved working directory and index state On master: second stashed files
    
    git stash list
    # stash@{0}: On master: second stashed files
    # stash@{1}: On master: first stashed files
    • Add a message to easily find what is all about that stash

Apply Stashed Files/Changes

Go Back to Summary

  • To apply back the changes

    • If we don't specify the stash number, git will apply the last stashed files (stash{0})
    git stash apply
  • To apply back a specific stash

    # git stash apply stash@{stash_number_here}
    
    git stash apply stash@{0}
    # On branch master
    # Your branch is up to date with 'origin/master'.
    
    # Changes not staged for commit:
    #   (use "git add <file>..." to update what will be committed)
    #   (use "git restore <file>..." to discard changes in working directory)
    #         modified:   README.md
    
    # no changes added to commit (use "git add" and/or "git commit -a")

Show Stashed Files/Changes

Go Back to Summary

  • Show all the files that you have stashed in your last stash

    git stash show
    # Config.md | 33 ++++++++++++++++++++++++-----
    # 1 file changed, 33 insertions(+), 5 deletions(-)
  • Show all the files that you have stashed of a specific stash

    # git stash show -p stash@{stash_number_here}
    
    git stash show -p stash@{1}
    # README.md | 24 +++++++++++++++++++++---
    # 1 file changed, 21 insertions(+), 3 deletions(-)

Rename Stashed Message

Go Back to Summary

  • This command will create a new stash with all the stashed files

    git stash store -m "your descriptive message here" stash@{1}

Delete Stashed Files/Changes

Go Back to Summary

  • Discard all the stashed files/changes in your last stash

    git stash drop
  • Discard all the stashed files/changes of a specific stash

    # git stash drop stash@{stash_number_here}
    
    git stash drop stash@{1}
    # Dropped stash@{1} (043540bb638a411a785ae34fb7a700ec08686611)

TRACK/UNTRACK FILES

Go Back to Summary

  • There are often times when you want to modify a file but not commit the changes, for example changing the database configuration to run on your local machine.

  • Adding the file to .gitignore doesn’t work, because the file is already tracked. Luckily, Git will allow you to manually “ignore” changes to a file or directory.

Untrack Pushed File (Similar to .gitignore)

Go Back to Summary

git update-index --assume-unchanged <filename>

Track Back Ignored Files

Go Back to Summary

git update-index --no-assume-unchanged <filename>

List Untracked Files

Go Back to Summary

  • If you forgot what file did you --assume-unchanged, you can call the list using the following command:

Windows Command

Go Back to Summary

git ls-files -v | findstr /B h

Mac/Unix Command

Go Back to Summary

git ls-files -v | grep '^h'

CHANGE COMMIT MESSAGE

Go Back to Summary

  • At some point you’ll find yourself in a situation where you need edit a commit message. That commit might already be pushed or not, be the most recent or buried below 10 other commits

Change Commit Message - Not Pushed

Go Back to Summary

  • This will open your $EDITOR and let you change the message. Continue with your usual git push origin master.

    git commit --amend

Change Commit Message - Already Pushed

Go Back to Summary

  • We edit the message like just above. But need to --force the push to update the remote history.

  • ⚠️ But! Force pushing your commit after changing it will very likely prevent others to sync with the repo, if they already pulled a copy. You should first check with them.

    git commit --amend
    git push origin master --force

Change Commit Message - Not Pushed + Old Commit

Go Back to Summary

  • Rebase opened your history and let you pick what to change. With edit you tell you want to change the message. Git moves you to a new branch to let you --amend the message. git rebase --continue puts you back in your previous branch with the message changed.

    git rebase -i HEAD~X       # X is the number of commits to go back
                                # Move to the line of your commit, change pick into edit
    git commit --amend         # Change your commit message
    git rebase --continue      # Finish the rebase

Change Commit Message - Already Pushed + Old Commit

Go Back to Summary

  • Edit your message with the same 3 steps process as above (rebase -i, commit --amend, rebase --continue). Then force push the commit:

    git push origin master --force
  • Find a commit that you want to edit

    git rebase --interactive '3b2155d^'
    • Select the commit that you want to edit (3b2155d)

    • Update the message

      git commit --amend -m "Should add new file + configuration"
      
      # [detached HEAD 17f6a6d] Should add new file + configuration
      # Date: Mon Jun 28 18:52:09 2021 -0400
      # 1 file changed, 0 insertions(+), 0 deletions(-)
      # create mode 100644 test.txt
    • After updating the message, continue rebase

      git rebase --continue
      
      # Successfully rebased and updated refs/heads/main.
    • Push force

      git push -f

⚠️ But! Remember re-pushing your commit after changing it will very likely prevent others to sync with the repo, if they already pulled a copy. You should first check with them.

CHANGE COMMIT DATE

Go Back to Contents

  • Change the last commit date before pushing to remote

    git commit --amend --no-edit --date="Fri Nov 6 20:00:00 2015 -0500"

BRANCH

Create a Branch

Go Back to Summary

git branch <branch name>

List All Branches local/remote

Go Back to Summary

git branch -a

Switch to Branch

Go Back to Summary

git checkout <branch name>

Create and Switch to Branch (in One Command)

Go Back to Summary

git checkout -b <branch name>

Push a Branch

Go Back to Summary

  • After You've Made the Changes on the Branch

  • Add and commit

    git add -A
    git commit -m "message"
  • After Commit, Push Branch to Remote (Origin/Branch)

    git push origin <branch name>

Merge a Branch to Master

Go Back to Summary

  • Merge a Branch to Local HEAD (Master) and Push to Master to Remote (Origin)

    git checkout master       # to change to master branch
    git pull origin master    # just to be sure that local master is up to date
    git branch --merged       # to check if the branch was merged, right now is just "master"
    git merge <branch name>   # to merge the changes to local master
    git branch --merged       # to check if the branch was merged
    git push origin master    # to push this changes to remote master

Delete a Branch

Go Back to Summary

git branch -d <branch name>              # to delete local branch
git push origin --delete <branch name>   # to delete remote branch

Rename Local Branch

Go Back to Summary

  1. Switch to the local branch which you want to rename:

    git checkout <old_name>
  2. Rename the local branch

    git branch -m <new_name>

Rename Remote Branch

Go Back to Summary

If you already pushed the branch to remote

  1. Rename your local branch

  2. Push the the <new_name> local branch and reset the upstream branch

    git push origin -u <new_name>
  3. Delete the <old_name> remote branch

    git push origin --delete <old_name>

DISCARD CHANGES

Discard Changes - Not Staged

Go Back to Summary

  • To revert the file back to the state it was in before the changes. This will put your local git (HEAD) on your last commit and will erase all your modifications.

    git checkout -- <filename>

UNSTAGE

Go Back to Summary

  • Remove from stage (after git add -A , git add <file> or git add .) - NOT COMMITTED FILES

Remove All From Stage - KEEP the Modifications

Go Back to Summary

  • To remove files from stage use reset HEAD. This will unstage the file(s) and KEEP all the modifications.

    git reset
    
    #or
    
    git reset HEAD          # unstage all files

Remove a Specific File From Stage - KEEP the Modifications

Go Back to Summary

  • Remove from stage (after git add -A or git add <filename>). This will unstage the file and KEEP all the modifications.

    git reset <filename>    # unstage a specific file

RESET

Reset HEAD Last Commit - KEEP Modifications NOT Staged

Go Back to Summary

  • This command will delete your last commit (not pushed) and all modification will be not staged, so you have to manually git add them back to stage.

    git reset HEAD~1
    • ~1 is the number of commit(s)
    • ~ vs ^

Reset HEAD Last Commit - KEEP Modifications Staged

Go Back to Summary

  • This command will delete your last commit (not pushed) and all modification will be in stage

    git reset --soft HEAD~1
    • ~1 is the number of commit(s)
    • ~ vs ^

Reset HEAD Stage - DISCARD the Modifications

Go Back to Summary

  • To remove files from stage use --hard reset HEAD. This will unstage the file(s) and DISCARD all the modifications.

    git --hard reset HEAD          # unstage all files

Reset HEAD to X Commits - DISCARD the Modifications

Go Back to Summary

  • This will DISCARD all the modifications and will set the HEAD to your previous commit(s).

    git reset --hard HEAD~1        # reset last commit
    • ~1 is the number of commit(s)
    • ~ vs ^

DELETE

Delete Pushed Files From Remote/Origin

Go Back to Summary

    1. Log all the pushed/committed files:
    git log --oneline
    268186e (HEAD -> master, origin/master, origin/HEAD) remove
    3bdb527 Week 4, Day 1 - Exercise 2 - Express
    1002de7 Week 4, Day 1 - Exercise 1 - Node
    5ed3cc5 rename folders
    bec7979 rename folders
    a6f5fe2 Week 4, Day 1 - Exercise 3 - Lab Express
    b707a70 Week 4, Day 1 - Exercise 2 - Express
    e10d893 Week 4, Day 1 - Exercise 1 - Node
    b92f8b6 Week 4, Day 1 - Exercise 3 - Lab Express
    1ad7b97 Week 4, Day 1 - Exercise 2 - Express
    05694f2 Week 4, Day 1 - Exercise 1 - Node
    1. Copy all the hashes that you want to delete from github
    268186e
    3bdb527
    1002de7
    5ed3cc5
    bec7979
    a6f5fe2
    b707a70
    e10d893
    b92f8b6
    1ad7b97
    05694f2
    1. Revert the local HEAD as many times you need:
    git reset HEAD~1        #this will revert the HEAD 1 commit and keep the modifications
    
    In this example, we are going to use
    
    git reset HEAD~11       #this will revert the HEAD 11 commits
    1. Delete from GitHub
    git push origin +268186e^:master
    git push origin +3bdb527^:master
    git push origin +1002de7^:master
    git push origin +5ed3cc5^:master
    git push origin +bec7979^:master
    git push origin +a6f5fe2^:master
    git push origin +b707a70^:master
    git push origin +e10d893^:master
    git push origin +b92f8b6^:master
    git push origin +1ad7b97^:master
    git push origin +05694f2^:master
    1. Double check if everything went all right:
    git pull origin master
    git status

Go Back to Summary

  • Using filter-branch

    • WARNING: If you run git filter-branch after stashing changes, you won't be able to retrieve your changes with other stash commands. Before running git filter-branch, we recommend unstashing any changes you've made. To unstash the last set of changes you've stashed, run git stash show -p | git apply -R
  1. Run the following command, replacing PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA with the path to the file you - want to remove, not just its filename. These arguments will:

    • Force Git to process, but not check out, the entire history of every branch and tag
    • Remove the specified file, as well as any empty commits generated as a result
    • Overwrite your existing tags
    git filter-branch --force --index-filter \
    "git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA" \
    --prune-empty --tag-name-filter cat -- --all
    # Example
    
    git filter-branch --force --index-filter \
    "git rm --cached --ignore-unmatch 3-Taks-Manager/env/dev.env" \
    --prune-empty --tag-name-filter cat -- --all
    
    # Rewrite 48dc599c80e20527ed902928085e7861e6b3cbe6 (266/266)
    # Ref 'refs/heads/master' was rewritten
  2. Add your file with sensitive data to .gitignore to ensure that you don't accidentally commit it again.

    # Example
    
    echo "YOUR-FILE-WITH-SENSITIVE-DATA" >> .gitignore
    git add .gitignore
    git commit -m "Add YOUR-FILE-WITH-SENSITIVE-DATA to .gitignore"
    
    # [master 051452f] Add YOUR-FILE-WITH-SENSITIVE-DATA to .gitignore
    #  1 files changed, 1 insertions(+), 0 deletions(-)
  3. Once you're happy with the state of your repository, force-push your local changes to overwrite your GitHub repository, as well as all the branches you've pushed up:

    git push origin --force --all
    # Example
    
    git push origin --force --all
    
    # Counting objects: 1074, done.
    # Delta compression using 2 threads.
    # Compressing objects: 100% (677/677), done.
    # Writing objects: 100% (1058/1058), 148.85 KiB, done.
    # Total 1058 (delta 590), reused 602 (delta 378)
    # To https://github.com/YOUR-USERNAME/YOUR-REPOSITORY.git
    #  + 48dc599...051452f master -> master (forced update)
  4. In order to remove the sensitive file from your tagged releases, you'll also need to force-push against your Git tags:

    git push origin --force --tags
    # Example
    
    git push origin --force --tags
    
    # Counting objects: 321, done.
    # Delta compression using up to 8 threads.
    # Compressing objects: 100% (166/166), done.
    # Writing objects: 100% (321/321), 331.74 KiB | 0 bytes/s, done.
    # Total 321 (delta 124), reused 269 (delta 108)
    # To https://github.com/YOUR-USERNAME/YOUR-REPOSITORY.git
    #  + 48dc599...051452f master -> master (forced update)

REVERT

Revert Full Commit

Go Back to Summary

  • Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

    git revert {hash key}

GITHUB GIST

Go Back to Summary

https://gist.github.com/Roger-Takeshita

  • Gist description: A brief description about your gist

  • File: Create any file just to GitHub let you create your gist

MULTIPLE GITHUB ACCOUNT

Generate a New SSH Key

Go Back to Contents

  • Generate a new ssh key using your new email

  • On Terminal:

    ssh-keygen -t rsa -C "your_new_email@gmail.com"
    # Generating public/private rsa key pair.
    # Enter file in which to save the key (/Users/roger-that/.ssh/id_rsa):
    /Users/roger-that/.ssh/id_rsa_dev
    # Enter passphrase (empty for no passphrase):
    your_password
    # Enter same passphrase again:
    your_password
    # Your identification has been saved in /Users/roger-that/.ssh/id_rsa_dev.
    # Your public key has been saved in /Users/roger-that/.ssh/id_rsa_dev.pub.
    # The key fingerprint is:
    # SHA256:I60nfahisdhfiahsidfhiasdifhiashyH4 your_new_email@gmail.com
    # The key's randomart image is:
    # +---[RSA 3072]----+
    # |                 |
    # |                 |
    # |                .|
    # |       .       ..|
    # |      k S    oo1.|
    # |     o +..  .d%+=|
    # |. . . =.c+  .-+*.|
    # | p D =a*+.o  o...|
    # |...  +Ffff +*f   |
    # +----[SHA256]-----+

Public SSH Key

Go Back to Contents

  • Copy your new public SSH key

    cat /Users/roger-that/.ssh/id_rsa_dev.pub
    
    # ssh-rsa AAAAB3NzafskdlfajsdjflajsdlfjalsdfeqlZwxFV4kMKsc9t8lAyS3DKWfahsidfhahsdifhaids/IDY+kfhakjsdhfkahsdkfhakshdfkaksdfoausdofuaosdufoausdofuoausdofuaosdufoausodfoausdofuaosdufoausdofuasdaosudfoasidfouaosdufoausdofuasdou/fa9sdf89as7d9f7a9sdf9as7df97as9df7a0s9df7a09sdf78asd98bxchvbixcvbkhxckvbxkchvlbxjcvklbjxlcjvb;xjcvblkxjcvb;jx;cvbj;xclvjb;xcv;lxkcjvb/26/oKMPWEZdoR7wvLVmjORn10ZQsIvI3swnwyxB7pxkaj;lsdfjka;sldjf;aklsjdf;alksjdf;lajsd;lfja;sdjfk;lajsdfl;kajs;dfja;lsdjf;alksdjf;ajsYhyZkz1XjaCobqTN+asdfkljasldfjalsjdflajsldkfjlajsd;g1uo1/qUg/DM= your_new_email@gmail.com

Add SSH Key To GitHub

Go Back to Contents

  • Go to Settings

  • Click on SSH and GPG keys > New SSH key

  • On SSH keys / Add new page

    • Title: Macbook

    • Key: paste your public key

    • Click on Add SSH key

Add New SSH Private Key To List

Go Back to Contents

  • Add the the new ssh key to our known key list

    ssh-add /Users/roger-that/.ssh/id_rsa_dev
    
    # Enter passphrase for /Users/roger-that/.ssh/id_rsa_dev:
    your_password
    
    # Identity added: /Users/roger-that/.ssh/id_rsa_dev (your_new_email@gmail.com)

Config

Go Back to Contents

  • In /Users/roger-that/.ssh/config (create one if file doesn't exist)

    Host unique_name
      HostName github.com
      User your_new_github_user
      IdentityFile /Users/roger-that/.ssh/id_rsa_dev

Add New Project Origin

Go Back to Contents

  • We need to set our remote origin slightly different

    # If you don't have set the origin
    git remote add origin git@unique_name:/roger-takeshita-dev/codebase.git
    
    # OR
    
    # If you cloned from github
    git remote set-url origin git@unique_name:/roger-takeshita-dev/codebase.git

HEROKU

LOGIN/CREATE

Login

Go Back to Summary

heroku login

Create App

Go Back to Summary

heroku create <app_name>

Associate Existing Heroku App

Go Back to Summary

heroku git:remote -a <app_name>

DEPLOY

Deploy to GitHub - Repo

Go Back to Summary

git push heroku master

Deploy to GitHub - Subtree

Go Back to Summary

git subtree push --prefix path/to/subdirectory heroku master
  • where path/to/subdirectory is the path to the project that you want to deploy to heroku
  • for example we have this repo
    • Inside we have a folder called 2_GraphQL_Prisma (we want to deploy this folder)
git subtree push --prefix 2_GraphQL_Prisma heroku master

About

My Git Cheat Sheet

Resources

License

Stars

Watchers

Forks

Packages

No packages published