Preparación y commit
Registra los cambios en el historial: add, commit y amend.
How staging and committing work in Git
Git records history in two steps. First git add places changes into the staging area (the index) - a draft of your next snapshot. Then git commit turns whatever is staged into a permanent commit with a message. The two-step design is deliberate: it lets you commit some of your edits while leaving the rest for a later, cleaner commit.
The third command in this group, git commit --amend, rewrites the most recent commit - the standard fix for a typo in the message or a file you forgot to stage. Together these three commands are the write path of Git: everything else in the tool exists to organize, combine, or undo what they record.
Preguntas frecuentes
What does git add actually do?
git add stages, git commit records. Use git add . for everything or git add -p to stage individual chunks.How do I commit all my changes in one command?
git commit -am "message" stages every modified tracked file and commits it in one step. Note that it skips brand-new (untracked) files - those still need an explicit git add first.Can I change a commit after making it?
git commit --amend replaces the last commit, letting you edit its message or include newly staged files. Only amend commits you have not pushed yet; amending rewrites history, which causes conflicts for anyone who already pulled it.