Save my changes: commit and push
When to use this: You edited some files and want them saved in Git and on GitHub (which triggers a Vercel deploy).
Before you start
Steps
-
See what changed
terminalgit status -sbLists changed files.
M= modified,??= new and untracked. The first line shows if you are ahead or behind the remote.Expected output
## main...origin/main M src/pages/index.astro ?? src/content/new-page.md
-
Stage the changes
terminalgit add -APuts all changes in the staging area. To commit only some files, name them:
git add src/pages/index.astro. -
Commit with a clear message
terminalgit commit -m "Add Vercel domain scenario"Saves the snapshot locally. Good message: short, present tense, says what and why (
Fix broken link on home page). Notupdateorstuff. -
Push to GitHub
terminalgit pushUploads the commit. If the branch is Vercel's production branch (
main), Vercel starts a production deploy automatically; other branches get a preview deploy.Expected output
To https://github.com/you/my-site.git 3f2a1b9..8c4d7e0 main -> main
How to verify it worked
git statussaysnothing to commit, working tree cleanandup to date with 'origin/main'.- The commit appears on GitHub, and a new deployment appears in Vercel.
How to undo it
Not pushed yet and want to undo the commit but keep the edits: see 'Undo my last commit'. Already pushed: use a revert commit instead.
Common errors and fixes
rejected ... (fetch first) or non-fast-forward GitHub has commits you do not. Run git pull, then git push again. See the 'push rejected' scenario. nothing to commit, working tree clean You have no changes, or they are in another folder. Check you saved the files and are in the right repo. The current branch has no upstream branch Run the command Git suggests: git push --set-upstream origin <branch>. Q&A
Why stage and commit as two steps?
Staging lets you choose exactly which changes go in a commit, so unrelated edits can become separate, clean commits.
What is git commit -am?
It stages and commits changes to files Git already tracks in one go. It does not include brand-new files, so use git add for those.
Does commit send anything to GitHub?
No. Commit is local. Only git push uploads to GitHub.