As independent developers, we don’t need to master every Git trick like a DevOps engineer at a Big Tech company. We have only one goal: Manage code safely and ship products smoothly.
This manual compiles the most frequently used commands during my development of RustleFlow, covering automated releases, disaster recovery, and daily workflows.
1. Releases & Tags (The CI/CD Trigger)
In my automation workflow (GitHub Actions), Git Tags are the sole “trigger” for building and releasing.
Standard Release Flow
When you are ready to release v0.1.0:
# 1. Create a local tag (Ensure version matches package.json or tauri.conf.json)
git tag v0.1.0
# 2. Push tag to remote (This triggers the Release Workflow)
git push origin v0.1.0
The “Regret Pill”: Deleting & Retagging
When setting up CI/CD for the first time, builds often fail. You’ll need to fix the code and re-trigger the build with the same version number.
Note: A Git Tag is just a sticky note; the GitHub Release is the target. Before retagging, it’s best to manually delete the failed Release draft on GitHub.
# 1. Delete local tag
git tag -d v0.1.0
# 2. Delete remote tag (Tell the server to rip off the sticky note)
git push --delete origin v0.1.0
# 3. Retag and push
git tag v0.1.0
git push origin v0.1.0
2. Fixes & Cleanup (Firefighting & OCD)
Fix Last Commit (Painless Correction)
Just hit git commit and realized you made a typo or missed a config file? Don’t reset. Use this to overwrite the previous commit record.
# 1. Modify files or stage missed files
git add .
# 2. Merge changes into the previous commit (No new commit ID generated)
git commit --amend --no-edit
# If you just want to rename the commit message:
git commit --amend -m "fix: corrected commit message"
The “Spring Cleaning” (.gitignore not working)
A classic trap: You added .jks or node_modules to .gitignore, but Git is still tracking them. This happens because the files were indexed before the rule was created.
Run this sequence to clear the index without deleting physical files:
# 1. Clear cache (Remove all files from staging area)
git rm -r --cached .
# 2. Re-add all files (Now .gitignore rules are forced to apply)
git add .
# 3. Commit changes
git commit -m "chore: refresh gitignore rules"
Undo Last Commit (Soft Landing)
If you want to withdraw the last commit but keep your code changes to reorganize them:
# Undo the last commit, but keep file changes (Soft Reset)
# Returns state to before "git add"
git reset --soft HEAD~1
Discard All Local Changes (The Nuclear Option)
Your code is a mess, nothing works, and you just want to go back to the last clean state. Use with caution!
git checkout .
# Or (more thorough)
git reset --hard
3. Branching Strategy (The Sandbox)
Even as a solo developer, don’t build complex features directly on main. Create a branch—it’s a “sandbox.” If you mess up, just delete the branch; your main program remains untouched.
# 1. Create and switch to a new branch (feat/xxx is a good habit)
git checkout -b feat/dev
# ... Code freely here. Break things. It doesn't matter ...
# 2. Feature done? Switch back to main
git checkout main
# 3. Merge the feature into main
git merge feat/dev
# 4. Delete the branch (clean up)
git branch -d feat/dev
4. Daily Loop (Muscle Memory)
The trilogy you will repeat countless times a day:
# 1. Check status (What changed?)
git status
# 2. Add all changes to staging
git add .
# 3. Commit with a message (feat: new feature / fix: bug fix)
git commit -m "feat: add login page"
Dealing with Conflicts (Don’t Panic)
When you git pull or git merge, Git might scream “Conflict”. This is just Git saying, “I don’t know which of these two lines to keep. You decide.”
- Open the conflicted file and search for
<<<<<<<. - You will see a structure like this:
<<<<<<< HEAD My Code (Current Branch) ======= Incoming Code (Remote or Merged Branch) >>>>>>> branch-name - Physically delete the parts you don’t want (including those angle brackets) and keep the code you want.
- Save the file, then run standard
git add .andgit commit.
5. Stashing (Context Switching)
You are coding, but suddenly need to fix an urgent bug. Your current code is broken and can’t be committed yet.
# "Freeze" your current workspace
git stash
# ... (Code is now clean, go fix that bug) ...
# Bug fixed? Restore your workspace
git stash pop
Lessons Learned
- On SSH Connections: If your network causes SSH timeouts with GitHub, don’t waste time debugging Git configs. The fastest solution is to modify
~/.ssh/configto use a proxy, or simply switch to HTTPS. - On Key Safety: Never commit
.jks,.env, or other secrets to the repo. Once pushed, they are in the history forever even if deleted. If this happens, use the “Spring Cleaning” method above or force overwrite history.
Stay Focused. Minimal Action. We don’t need to be Git experts; we just need Git to be the solid foundation for shipping our products.