@Mureinik का उत्तर अच्छा है लेकिन नौसिखिया द्वारा समझा नहीं जा सकता है।
पहली विधि:
- यदि आप केवल नवीनतम प्रतिबद्ध संदेश को संपादित करना चाहते हैं, तो आपको केवल आवश्यकता है
git commit --amend, आप देखेंगे:
<your existing commit mesage foo bar>
# Please enter the commit message fir your changes. Lines starting
# with # will be ignored, and an empty message aborts the commit.
#
# Date: Sat Aug 24 17:56:16 2019 +0800
#
# On branch is up to date with 'origin/master'.
#
# changes to be committed:
# modified: foo.py
#
- जैसा कि आप देख सकते हैं, शीर्ष पर संदेश को बिना किसी उपसर्ग के जैसे कि
pick, यह पहले से ही संपादित पृष्ठ है और आप शीर्ष संदेश को संपादित कर सकते हैं और सहेज सकते हैं और छोड़ सकते हैं , जैसे:
<your new correction commit message>
# Please enter the commit message for your changes. Lines starting
....
- फिर करो
git push -u origin master --forceया <how you push normally> --force। यहाँ कुंजी है --force।
दूसरी विधि:
आप git logरिपॉजिटरी url से कमिट हैश को देख सकते हैं या निकाल सकते हैं , उदाहरण मेरे मामले में है881129d771219cfa29e6f6c2205851a2994a8835
तो आप कर सकते हैं git rebase --interactive 881129d771219cfa29e6f6c2205851a2994a8835या git rebase -i HEAD^(यदि नवीनतम)
तुम देखोगे:
pick <commit hash> <your current commit message>
# Rebase 8db7e8b..fa20af3 onto 8db7e8b
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
- लेकिन अगर आप देखते हैं कि आप
noopशायद गलत टाइप कर रहे हैं, जैसे यदि आप ऐसा करते हैं git rebase -i 881129d771219cfa29e6f6c2205851a2994a88जो ^अंत में गायब है , तो आप बेहतर तरीके से संपादक को बिना सेव किए छोड़ देते हैं और कारण का पता लगा सकते हैं:
noop
# Rebase 8db7e8b..fa20af3 onto 8db7e8b
...
- यदि कोई
noopसमस्या नहीं है, तो बस शब्द pickको बदल दें reword, अन्य बस बनी हुई है (आप इस बिंदु पर प्रतिबद्ध संदेश संपादित नहीं करते हैं), उदाहरण के लिए:
reword <commit hash> <your current commit message>
# Rebase 8db7e8b..fa20af3 onto 8db7e8b
#
# Commands:
# p, pick = use commit
...
- सहेजें और छोड़ें # 1 विधि के समान संपादन पृष्ठ देखेंगे :
<your existing commit mesage foo bar>
# Please enter the commit message fir your changes. Lines starting
# with # will be ignored, and an empty message aborts the commit.
#
# Date: Sat Aug 24 17:56:16 2019 +0800
#
# interactive rebase in progress; onto b057371
# Last command done (1 command done):
# reword d996ffb <existing commit message foo bar>
# No commands remaining.
# You are currently editing a commit while rebasing branch 'master' on 'b057371'.
#
# changes to be committed:
# modified: foo.py
#
- संदेश को शीर्ष पर संपादित करें, जैसे विधि # 1 और सहेजें और छोड़ें, जैसे:
<your new correction commit message>
# Please enter the commit message for your changes. Lines starting
....
- फिर से, # 1 विधि की तरह, करो
git push -u origin master --forceया <how you push normally> --force। यहाँ कुंजी है --force।
अधिक जानकारी के लिए कृपया डॉक पढ़ें ।