A heavier session today — some solid React mental models and then a proper deep dive into Git stash and diff commands. The kind of stuff that makes you feel a lot more comfortable in the terminal.
Arrays and Objects — They Work Differently, Treat Them Differently
In React (and JavaScript in general) these two are not interchangeable and the way you access data from each one reflects that.
With arrays, position is everything. You access data by index — items[0], items[2]. The order matters, the number matters.
With objects, it's all about the key. You access data by name — user.name, product.price. Just writing user alone won't print anything useful — you have to tell it which property you want. object.name is mandatory, not optional.
Small distinction on paper, massive difference in practice when you're debugging why something isn't rendering.
How content[activeContent] Actually Works
This is a really elegant pattern once you see what's happening behind the scenes:
{content[activeContent]}
activeContent is a state variable — say it's currently 2. So React reads this as content[2] and pulls whatever is sitting at index 2 of your content array. The user clicks something, activeContent updates to 3, React re-renders, and now it reads content[3].
Your array stays static. Your state changes. The combination of the two is what makes the UI feel dynamic. Clean and simple.
git log A..B — What Does B Have That A Doesn't?
The .. syntax reads left to right — "show me commits that are in B but NOT in A":
git log main..feature
This shows you everything feature has that main doesn't yet. Useful when you want to review what a branch is about to bring in before merging.
Renaming a Branch
If you're already on the branch:
git branch -m newname
If you're on a different branch and want to rename another one:
git branch -m oldname newname
git diff A..B — Comparing Actual File Changes
While git log shows commits, git diff shows the actual line-by-line changes between two points:
git diff main..feature
And two flags that make the output a lot more readable:
--name-only → just the file names, nothing else
--name-status → file names plus what happened to them — A for added, M for modified, D for deleted
git diff main..feature --name-status
Also worth knowing — when you're already on one of the branches, you don't need to type its name. Git knows where you are.
Git Stash — The Full Toolkit
You already know the basics of stash from a previous session. Today filled in the rest of the picture.
Save with a label — so you actually know what's in there later:
git stash push -m "navbar responsive fix"
See everything you've stashed:
git stash list
Peek inside a specific stash before applying it:
git stash show stash@{1}
Apply a stash without removing it from the list:
git stash apply stash@{1} or git stash apply 1
Apply AND remove it from the list at the same time:
git stash pop stash@{1}
Delete one specific stash permanently:
git stash drop stash@{1} or git stash drop 1
Nuke all stashes at once:
git stash clear
The index in stash@{1} refers to the stash list position — not any file index. Easy thing to mix up early on.
git config merge.ff false — Forcing Merge Commits
By default Git uses fast-forward merges when possible — meaning it just moves the branch pointer forward without creating a merge commit, keeping history linear. Sometimes that's fine. But if you want your history to always show "these commits came in from a branch" with a proper merge commit, disable it:
git config merge.ff false
This applies to the current repo only. Useful in team projects where you want a clear record of when and what was merged.
Top comments (0)