首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >合并打开VIM后的Git提交

合并打开VIM后的Git提交
EN

Stack Overflow用户
提问于 2012-02-09 02:26:12
回答 3查看 15.3K关注 0票数 16

我做了2个文件的合并,现在我正在尝试提交,但它打开VIM与以下数据,现在我完全迷路了。(我没有使用VIM的经验)

代码语言:javascript
复制
Merge branch 'master' of nodester.com:/node/git/lolcoder/****-******

Conflicts:
        .gitignore
        server.js
#
# It looks like you may be committing a merge.
# If this is not correct, please remove the file
#       .git/MERGE_HEAD
# and try again.


# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#   
#       .project
~                                                                               
~                                                                               
~                                                                               
".git/COMMIT_EDITMSG" 19L, 521C                               1,1           All

从这里我该怎么做?

以下是场景:

我在github上有一个node.js项目,现在我正试着把它推到nodester的git repo上(所以我现在有两个遥控器用于我的项目)。但是在我可以推送到nodester之前,我需要修复两个文件,这两个文件与我在nodester上生成的文件冲突。我用git merge -y解决了冲突,现在我想提交然后推送。

这是我尝试推送到nodester时得到的错误:

代码语言:javascript
复制
Nodester!
To git@nodester.com:/node/git/lolcoder/****-**************.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@nodester.com:/node/git/lolcoder/****-************.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-02-09 02:33:05

Git打开vim是因为您的环境变量EDITOR设置为vim,并且Git认为您需要为合并操作提供提交消息,因此它将打开一个编辑器供您输入一个。

可以通过将环境的EDITOR变量更改为您喜欢的变量,或者在git merge -y后提供-- message“this is my commit message”参数来修复此问题

票数 17
EN

Stack Overflow用户

发布于 2016-04-07 15:34:35

如果您想要的是执行合并并避免打开任何文本编辑器,则可以向merge命令添加--no-edit,这样它就不会打开提交消息的编辑器。

票数 5
EN

Stack Overflow用户

发布于 2020-06-16 13:36:45

如果您希望完全跳过文本编辑器,而使用默认的合并消息,只需在.bash_profile.bashrc.zshrc文件中添加以下行:

代码语言:javascript
复制
export GIT_MERGE_AUTOEDIT=no
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9199222

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档