Saturday, August 29, 2020

Pushing and Pulling Commits between Visual Studio Code and Github.com

CREATE NEW REPO, empty, from the github server side: (leave out README.md)
When presented with new URL, copy the URL
Locally, mkdir myrepofolder, cd myrepofolder, and create README.md (case-sensitive)

git init
git add README.md
git commit -m "first commit"
git branch -M master
git remote add origin https://github.com/mygithubusername/myrepofolder.git
git push -u origin master

PUSH COMMITS TO GITHUB
git add README.md
git commit -m "ongoing edits"
[master 6c0e1bd] ongoing edits
1 file changed, 1 insertion(+), 5 deletions(-)
git push -u origin master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 328 bytes | 328.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/myusername/myrepofolder.git
383e4f7..6c0e1bd master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'


PULL COMMITS FROM GITHUB
git pull origin master

TIPS FOR USING THE VIM EDITOR
i edit and use arrow keys to navigate
esc finish editing
:w!enter save changes
:q!enter quit VIM EDITOR
# comment-out line character

Mac Terminal Update

MacOS changed the default TERMINAL shell from bash to zsh with the Catalina release (10.15.x). (echo $SHELL tells you what shell terminal is using). This means customizing your terminal prompt from .bash_profile no longer works. The solution is to create a .zshrc file in your home (username) directory and insert the following line: (dot files are hidden by default on mac, view in finder by hitting command-shift-dot while in the folder with hidden files)

PROMPT='%F{green}%1~ $ %f'

This customizes the prompt to include the current directory name (%1~), to use the $ character as the prompt with a space on either side, and to be green (%F{colorselection}%f)

The customization automatically works with VISUAL STUDIO CODE (which I now am using in place of Sublime Text as a text editor / code editor, because it includes a Terminal window).