Back to Articles
Git Oct 27, 2026 2 min read

Git Workflow Notes — Stash, Cherry-Pick & Build Cleanup

Day to day usage of life saving git command in real life complex senario

Git Workflow Notes — Stash, Cherry-Pick & Build Cleanup

1. Stash current changes

git stash push -m "WIP: First Build"

Purpose: Temporarily saves tracked and staged changes and restores a clean working tree.

Usage: Run before switching branches or cherry-picking when you have uncommitted changes. Untracked files are not included by default.

To restore the stashed changes later:

git stash list
git stash pop

2. Cherry-pick a specific commit

git cherry-pick f5f6d786

Purpose: Applies the changes from the specified commit to your current branch without merging the entire source branch.

Usage: Switch to the intended target branch first and verify your working tree is clean.

If conflicts occur, resolve them and run:

git add <resolved-file>
git cherry-pick --continue

To cancel an in-progress cherry-pick:

git cherry-pick --abort

3. Ignore local .NET build outputs

@'

# Local .NET build outputs
**/bin/
**/obj/
.vs/
'@ | Add-Content .git/info/exclude

Purpose: Locally ignores matching untracked build files without changing the shared .gitignore or creating a commit.

Usage: Run from the repository root. Add these rules only once to avoid duplicates.

Note: This does not hide changes to files already tracked by Git.

4. Restore modified build-generated text files

git restore -- "*/obj/Debug/*.csproj.FileListAbsolute.txt"

Purpose: Restores matching tracked files to their committed versions, discarding local modifications.

Usage: Run after a build if these generated files appear as modified in Git status.

Warning: Any local changes to matching files will be lost. These files may become modified again after the next build.

5. Verify the working tree

git status --short

Shows staged, modified, and untracked files so you can verify the results before committing or pushing.

Share this article

Dabananda Mitra

Dabananda Mitra

Software Engineer specializing in scalable backend systems and minimal, effective API design.

Comments

Loading comments...