https://stackoverflow.com/questions/37505484/cant-exit-git-commit-in-windows

本文介绍如何在Windows环境下使用Git完成提交操作。当用户在PowerShell中输入git commit命令后,会进入一个编辑器界面来填写提交说明。文章详细解释了如何通过输入特定命令退出编辑器并完成提交。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

From Powershell I've called git commit and it presents me with

enter image description here

I typed the commit message (in yellow) but I have no idea what to do next. Pressing Enter just adds a newline to my input. How do I complete the commit? I've been through several tutorials but none of them explained the next step.

EDIT: So I found I can press : to make the cursor jump to the bottom line, then type wq to complete the commit. What exactly is this? Is it correct? Are there any alternatives?

share improve this question
 
1  
You can also use :x<cr> or just ZZ [no <cr> needed and which is shortand for the :x]. These have the virtue [over :wq] that they will terminate vi but will not write to the file (i.e. change the mtime) unless [pending] changes have been made in the vi edit. –  Craig Estey  May 29 '16 at 3:14
 
Possible duplicate of How to exit the VIM editor? –  1615903  May 30 '16 at 5:49
 
And if you prefer some other editor, see here for how to configure: stackoverflow.com/q/2596805/1615903 –  1615903  May 30 '16 at 5:50

1 Answer

up vote 3 down vote accepted

After typing the message, press Escape to exit insert mode and then type :wq (write/save and quit, or :q! if you want to cancel and return to the prompt). Alternatively, you can commit in one step by typing git commit -m "message"


https://stackoverflow.com/questions/37505484/cant-exit-git-commit-in-windows

From Powershell I've called git commit and it presents me with

enter image description here

I typed the commit message (in yellow) but I have no idea what to do next. Pressing Enter just adds a newline to my input. How do I complete the commit? I've been through several tutorials but none of them explained the next step.

EDIT: So I found I can press : to make the cursor jump to the bottom line, then type wq to complete the commit. What exactly is this? Is it correct? Are there any alternatives?

share improve this question
 
1  
You can also use :x<cr> or just ZZ [no <cr> needed and which is shortand for the :x]. These have the virtue [over :wq] that they will terminate vi but will not write to the file (i.e. change the mtime) unless [pending] changes have been made in the vi edit. –  Craig Estey  May 29 '16 at 3:14
 
Possible duplicate of How to exit the VIM editor? –  1615903  May 30 '16 at 5:49
 
And if you prefer some other editor, see here for how to configure: stackoverflow.com/q/2596805/1615903 –  1615903  May 30 '16 at 5:50

1 Answer

up vote 3 down vote accepted

After typing the message, press Escape to exit insert mode and then type :wq (write/save and quit, or :q! if you want to cancel and return to the prompt). Alternatively, you can commit in one step by typing git commit -m "message"

From Powershell I've called git commit and it presents me with

enter image description here

I typed the commit message (in yellow) but I have no idea what to do next. Pressing Enter just adds a newline to my input. How do I complete the commit? I've been through several tutorials but none of them explained the next step.

EDIT: So I found I can press : to make the cursor jump to the bottom line, then type wq to complete the commit. What exactly is this? Is it correct? Are there any alternatives?

share improve this question
 
1  
You can also use :x<cr> or just ZZ [no <cr> needed and which is shortand for the :x]. These have the virtue [over :wq] that they will terminate vi but will not write to the file (i.e. change the mtime) unless [pending] changes have been made in the vi edit. –  Craig Estey  May 29 '16 at 3:14
    
Possible duplicate of How to exit the VIM editor? –  1615903  May 30 '16 at 5:49
    
And if you prefer some other editor, see here for how to configure: stackoverflow.com/q/2596805/1615903 –  1615903  May 30 '16 at 5:50

1 Answer

up vote 3 down vote accepted

After typing the message, press Escape to exit insert mode and then type :wq (write/save and quit, or :q! if you want to cancel and return to the prompt). Alternatively, you can commit in one step by typing git commit -m "message"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值