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.
| Scenario | Action |
|---|---|
| Branch merged | Start a new branch from main |
| Branch not merged | Continue 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 initgit 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]
| Step | Command | Purpose |
|---|---|---|
| 1️⃣ | git checkout master | Switch to target branch |
| 2️⃣ | git pull origin master | Update with latest code |
| 3️⃣ | git merge develop | Merge 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 origingets your teammate’s update but doesn’t change your file.git reset --hard origin/masterthen deletes your version and makes your files match GitHub exactly.
| Step | Command | Local hello.txt says | Remote 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 origin | git fetch origin | “Hello from me” | “Hello from teammate” |
You run git reset --hard origin/master | git 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.
Command What 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.
| Type | Visibility | Accessible by search? | Use case |
|---|---|---|---|
| Public Gist | Anyone can see it | ✅ Yes | Sharing code openly |
| Secret Gist | Only those with the link | 🚫 No | Personal 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.
Command What it Does git fetch originDownloads changes from the remote (but doesn’t merge them). git pull origin mainDownloads and merges changes from the remote mainbranch into your current branch.git push origin mainUploads (pushes) your local mainbranch 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 / Action | git pull | git fetch |
|---|---|---|
| What it does | Downloads latest changes and merges them into your current branch | Downloads latest changes from remote but does not merge |
| Effect on local files | Your local branch is updated automatically | Local branch stays the same, only remote tracking branches are updated |
| Use case | Everyday workflow: start working with the latest code | Advanced: check remote changes before merging, or inspect code safely |
| Commands | git pull | git fetch |
| Next step after command | You can continue coding; no further merge required | You must manually merge if you want changes in your local branch: git merge origin/main |
| Risk | Low if you pull often; may cause merge conflicts if local changes conflict | Very safe; does not touch your files |
| Shortcut explanation | git pull = git fetch + git merge | Fetch only = just downloads commits from remote |
- Use
git pullfor the regular multi-user workflow (start work, sync changes). - Use
git fetchonly if you want to inspect remote changes without touching your local code.