wtsang11 / TechExplore

MIT License
0 stars 0 forks source link

Introduction #174

Open wtsang11 opened 2 years ago

wtsang11 commented 2 years ago

http://localhost/TechNotes/wp-admin/post.php?post=1432&action=edit

VSC: http://localhost/lab/python/utilities/study_codes/opencodes.php?f=/Users/wtsang/Lab/development_tools/colt_git/

Doc https://git-scm.com/

Git UI Tool: gitkraken.com

wtsang11 commented 2 years ago

Make VS Code a default editor for git commit:

git config --global core.editor "code --wait"

note: code is the command line command to run vs code. If the command code needs to be enabled in vs code such that the command is in the path. To avoid seeing a long commit message in git log, use --oneline flag.

Tips: commit should be atomic. use present tense, imperative words in commit message. The first line is a summary of the commit message. Use .gitignore file to list files and folders to ignore by git. Use the site https://www.toptal.com/developers/gitignore

ref: https://git-scm.com/book/en/v2/Appendix-C%3A-Git-Commands-Setup-and-Config

wtsang11 commented 2 years ago

Diff Utility

Git Diff https://www.canva.com/design/DAEVUT6HslA/tbdbyITzamUidWfk-HcSug/view?utm_content=DAEVUT6HslA&utm_campaign=designshare&utm_medium=link&utm_source=sharebutton#1

-- Difference between working directory and staging area git diff

-- Difference between working directory and HEAD (latest commit) git diff HEAD

-- Difference between staged and commit git diff --staged (or --cached)

-- Difference between two branches git diff [filename]

wtsang11 commented 2 years ago

Using Stash

-- stash changes not committed before switching to another branch git stash

-- On return, get back changes not committed. -- The option pop means to pop the latest stash from the stack of stashes if -- multiple stashes were made. git stash pop

-- Apply stashed changes in other branch. -- Apply will not remove changes from stash, Pop will. get stash apply

-- stashing can be done multiple times. -- To see the stashes: git stash list -- Apply a stash by its id eg 2 git stash apply stash@{2}

-- Delete a stash by id eg 0 git stash remove stash@{0}

-- Remove all stashes git stash clear

wtsang11 commented 2 years ago

Operating Tips

-- warning message on git init: Using 'master' as the name for the initial branch. This default branch name ... hint: is subject to change. -- Soltution: -- keep using master as the default branch name: git config --global init.defaultBranch master

-- ammend previous commit git add -- this will open configured editor to change previous commit message git commit --amend