VIM prompt “:”

  • :wq → save & quit
  • :q! → quit without saving

GitHub Token Location + Brew Installaiotn commands (One Time):

  • Token Setup: GitHub → Profile Icon → Settings → Developer settings → Personal access tokens → Tokens Modern One (Not Classic). Use this when it asked you the password.
  • commands for homebrew + git
brew install git
brew --version
 # Run these commands in your terminal to add Homebrew to your PATH:
    echo >> /Users/fewsteps/.zprofile
    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/fewsteps/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"

GitHub Workflow for Multiple Users and Devices — Complete Command Guide

git pull origin main                            # 1. Get latest project (always do this first)
git checkout -b my-feature-branch    # 2. Create your own branch (give your branch a unique name)
# (edit code normally)               # 3. Make changes to your files
git add .                            # 4. Stage and commit your changes
git commit -m "my update"
git push origin  my-feature-branch   # 5. Push your branch to GitHub
                                     # 6. Go to GitHub website
#  → Open Pull Request → Merge branch into main  (No terminal command — you click  buttons on GitHub)
git checkout main                   # 7. After the PR is merged, update your local main
#     git pull origin main          # beginning of thask

Future Modifications Workflow

After a branch is merged, create a new branch for any new changes.

ScenarioAction
Branch mergedStart a new branch from main
Branch not mergedContinue on the same branch

Tip: Pull the latest main before creating a new branch.

Summary of git commands

  • Tell Git who you are
    • git config --global user.name "Few Steps" [configure your Git user name]
    • git config --global user.email hellofewsteps@icloud.com [configure your Git email]
  • First Time Only
    • git init
    • git remote add origin <serve/urlr> [Connect to a remote repository]
    • git clone <remoteURL> [Clone remote to local [First Time Only]]
  • two ways to save
    • git add . [staging, ‘.’ means all]
    • git commit -m “comment or message” [committing]
  • Save to remote and update local
    • git push origin <branchName> [master/develop] [push commits to remote]
    • git pull origin <branchName> [master/develop] [pull latest code from remote branch]
    • git merge <branchName> [merge a different branch into active branch]
      • merge flow: [switchBranch] → [updateCode(active branch’s)] → [merge other branch]
StepCommandPurpose
1️⃣git checkout masterSwitch to target branch
2️⃣git pull origin masterUpdate with latest code
3️⃣git merge developMerge another branch
  • debugging
    • git status [show stage status]
    • git branch [show all branches and current branch]
  • branches
    • git checkout [] <branchName>
      • [if ‘-b’: create new branch, empty: switch]
    • git push origin <branchname> [Push the branch to remote repository]
    • git push --all origin [push all branches to remote repository]
    • git branch -d <branchName> [-D: force delete local branch] [Delete local branch]
    • git push origin --delete dev2 [Delete remote branch]
    • git push origin :<branchname> [delete a branch on remote repository]
  • Undo local changes
    • git fetch origin [fetch latest history from remote]
    • git reset --hard origin/master [reset local branch to remote]
    • Explanation:
      • You changed a file locally, and your teammate updated it on GitHub.
      • git fetch origin gets your teammate’s update but doesn’t change your file.
      • git reset --hard origin/master then deletes your version and makes your files match GitHub exactly.
StepCommandLocal hello.txt saysRemote hello.txt says
Start—“Hello World”“Hello World”
You edit—“Hello from me”“Hello World”
Teammate pushes—“Hello from me”“Hello from teammate”
You run git fetch origingit fetch origin“Hello from me”“Hello from teammate”
You run git reset --hard origin/mastergit reset --hard origin/master“Hello from teammate”“Hello from teammate”
  • Others

    • git diff [view all merge conflicts]
    • git diff –base [view conflicts against base file]
    • git diff [preview changes before merging]
    • git tag 1.0.0 [tag a specific commit]
    • git log [view commit IDs]
  • Search

    • git grep “foo()"` [search working directory for a string]
  • git stash: is a temporary storage feature in Git — it lets you save your uncommitted changes (like edited files) without committing them and return to a clean working directory.

    CommandWhat it does
    git stashSave (stash) your uncommitted changes.
    git stash listShow all stashes you’ve saved.
    git stash popReapply the most recent stash and remove it from the list.
    git stash applyReapply a stash but keep it in the list.
    git stash dropDelete a specific stash.
    git stash clearRemove all stashes.
  • .gitignore file: is a plain text file that tells Git which files or folders it should ignore — meaning not track, commit, or push to your repository.

    • add .gitignore on root folder
    • If you’ve already had files tracked that should be ignored now (e.g., target/ or reports), you’ll need to remove them from tracking first:
      • git rm -r --cached target/ allure-results/ test-output/
      • git commit -m "Remove ignored files from tracking
    • check hidden files on mac: Command + Shift + .
  • Gist: A Gist is a simple way to share code snippets, notes, or small files using GitHub. Every Gist is actually a Git repository.

TypeVisibilityAccessible by search?Use case
Public GistAnyone can see it✅ YesSharing code openly
Secret GistOnly those with the link🚫 NoPersonal notes or sharing privately

Origin

  • In Git, origin is the default name for the remote repository your local project is connected to. A remote is just a URL link to another copy of your repository (often on GitHub, GitLab, or Bitbucket). When you clone a repository, Git automatically creates this remote and names it origin.
    CommandWhat it Does
    git fetch originDownloads changes from the remote (but doesn’t merge them).
    git pull origin mainDownloads and merges changes from the remote main branch into your current branch.
    git push origin mainUploads (pushes) your local main branch to the remote.
    git remote -vShows all remotes and their URLs.
    git remote add origin <url>Connects your local repo to a new remote repository.

Reset Git History and Push Hugo Site as New Project

  • delete .git and .gitsubmodule
rm -rf .git                                  # 1️⃣ Delete existing Git history
git init                                     # 2️⃣ Reinitialize Git
git add .                                    # 3️⃣ Add all files (except .gitignore files)
git commit -m "Initial commit - fresh start" # 4️⃣ Commit as a fresh start
git remote add origin <your-github-repo-url> # 5️⃣ Add GitHub remote
git branch -M main                           # 6️⃣ Make sure branch is main
git push -f origin main                      # 7️⃣ Force push to GitHub (overwrite history)

Git Commands: git pull vs git fetch — Side by Side

Feature / Actiongit pullgit fetch
What it doesDownloads latest changes and merges them into your current branchDownloads latest changes from remote but does not merge
Effect on local filesYour local branch is updated automaticallyLocal branch stays the same, only remote tracking branches are updated
Use caseEveryday workflow: start working with the latest codeAdvanced: check remote changes before merging, or inspect code safely
Commandsgit pullgit fetch
Next step after commandYou can continue coding; no further merge requiredYou must manually merge if you want changes in your local branch: git merge origin/main
RiskLow if you pull often; may cause merge conflicts if local changes conflictVery safe; does not touch your files
Shortcut explanationgit pull = git fetch + git mergeFetch only = just downloads commits from remote
  • Use git pull for the regular multi-user workflow (start work, sync changes).
  • Use git fetch only if you want to inspect remote changes without touching your local code.

Ref: