Git commit Command
In this page:
git commit -m "commit message"
git commit -am "commit message"
git commit --amend
एक Message के साथ Commit करना
git commit -m "message" इस समय staged हर चीज़ को आपके project की history में एक नए permanent snapshot की तरह save करता है। message कोई optional busywork नहीं है -- क्या बदला इसका एक specific, honest description महीनों बाद git log को उपयोगी बनाता है।
उदाहरण: Committing with a Message
git commit -m "Fix login button alignment"
एक Step में Staging और Committing
git commit -am "message" Git पहले से track की गई files के लिए staging और committing combine करता है, अलग git add step skip करते हुए -- लेकिन ध्यान दें shortcut सिर्फ tracked files में modifications पकड़ता है, यह कभी आपके लिए एक बिल्कुल नई untracked file stage नहीं करेगा।
उदाहरण: Staging and Committing in One Step
git commit -am "Update styles"
Last Commit Amend करना
git commit --amend आपकी सबसे हाल की commit को पूरी तरह replace कर देता है -- एक corrected message, एक भूली हुई file add, या दोनों के साथ -- एक नई commit बनाने के बजाय। यह गलती को उसके seconds बाद fix करने के लिए convenient है, लेकिन पहले से push और shared की गई commit को amend करने से बचें।
उदाहरण: Amending the Last Commit
git commit --amend
एक Detailed Description के साथ Commit करना
एक change के लिए जिसे एक line से ज़्यादा explanation चाहिए, git commit -m "Title" -m "Longer paragraph explaining why" चलाना एक छोटी summary line और एक अलग detailed body वाली एक commit बनाता है, ज़्यादातर Git tools की expected conventional format से match करते हुए।
उदाहरण: Committing with a Detailed Description
git commit -m "Fix login bug" -m "The button was not responding on mobile Safari due to a missing touch event handler."
Empty Commits
git commit --allow-empty zero file changes वाली एक commit बनाता है, जो useless लगता है लेकिन एक CI/CD pipeline manually trigger करने के लिए, या बिना कोई code बदले history में एक meaningful milestone mark करने के लिए genuinely handy है।
उदाहरण: Empty Commits
git commit --allow-empty -m "Trigger CI pipeline"
- बिना
-mकेgit commitचलाना और Vim जैसे एक editor में drop हो जाना, यह न जानते हुए कि कैसे save और exit करें। git commit -amइस्तेमाल करना और नई untracked files के शामिल होने की उम्मीद करना, जबकि-aसिर्फ Git की पहले से tracked files stage करता है।- पहले से push की गई commit पर
git commit --amendइस्तेमाल करना, जो history rewrite करता है और दूसरों को conflicts से deal करने पर मजबूर करता है।
Chapter Quiz — Complete all 18 topics to unlock
0/18 topics done
Complete these topics first:
- Git init Command
- Git New Files
- Git Staging Environment
- Git clone Command
- Git status Command
- Git help Command
- Git add Command
- Git commit Command
- Git tags Command
- Git stash Command
- Git log Command
- Git diff Command
- Git show Command
- Git rm Command
- Git mv Command
- Git restore Command
- Git clean Command
- Git ignore (.gitignore)