What Happens When You Publish a Container's Port? 🧵
"Port publishing" might be a term coined by Docker.
But "port forwarding" or "port mapping" - as a form of socket redirection - was a widespread trick well before the invention of containers. How are the two different?
Git Merge vs. Rebase vs. Squash Commit
What are the differences?
When we 𝐦𝐞𝐫𝐠𝐞 𝐜𝐡𝐚𝐧𝐠𝐞𝐬 from one Git branch to another, we can use ‘git merge’ or ‘git rebase’. The diagram below shows how the two commands work.
𝐆𝐢𝐭 𝐌𝐞𝐫𝐠𝐞
This creates a new commit G’ in the main branch. G’ ties the histories of both main and feature branches.
Git merge is 𝐧𝐨𝐧-𝐝𝐞𝐬𝐭𝐫𝐮𝐜𝐭𝐢𝐯𝐞. It introduces a new commit to the main branch without altering the existing commits in either branch.
𝐆𝐢𝐭 𝐑𝐞𝐛𝐚𝐬𝐞
Git rebase transplants the feature branch histories to the tip of the main branch. It creates new commits E’, F’, and G’ for each commit in the feature branch.
The benefit of rebase is that it has 𝐥𝐢𝐧𝐞𝐚𝐫 𝐜𝐨𝐦𝐦𝐢𝐭 𝐡𝐢𝐬𝐭𝐨𝐫𝐲.
However, be cautious: abide by the 𝐆𝐨𝐥𝐝𝐞𝐧 𝐑𝐮𝐥𝐞 𝐨𝐟 𝐆𝐢𝐭 𝐑𝐞𝐛𝐚𝐬𝐞 — Never use it on shared branches to avoid confusing collaborators.
𝐆𝐢𝐭 𝐒𝐪𝐮𝐚𝐬𝐡 𝐂𝐨𝐦𝐦𝐢𝐭 (not shown)
Squashing condenses multiple commits into one, streamlining the commit history.
When to use each one is a bit nuanced. We have a YouTube video to explain it clearly. Link in comment below.
–
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): https://t.co/kNfv0DVDdf