Learn how to preview file changes using git diff, stage them with git add, and commit safely—step-by-step instructions for GitHub workflow.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
Step 1: Open your terminal and navigate to your local repository
cd /path/to/your/local/repo
Step 2: Check the status of your working directory
git status
Step 3: Preview all unstaged changes using git diff
git diff
Step 4: Preview changes in a specific file
git diff
.git diff path/to/your/file.ext
Step 5: Stage changes and preview staged (to-be-committed) diffs
# Stage a single file
git add path/to/your/file.ext
# Or stage all changes
git add .
git diff --staged
Step 6: Use an external diff tool (optional)
git difftool
:# Launch your configured external diff tool
git difftool
# Or view only staged changes
git difftool --staged
diff.tool
in your ~/.gitconfig
.
Step 7: Commit once you’re satisfied with the preview
git commit -m "Describe your changes clearly"
git push origin main
Now you’ve safely previewed your file changes before committing and pushed them up to GitHub!
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.