合并后 Git Commit 打开 VIM

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9199222/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 06:27:19  来源:igfitidea点击:

Git Commit after merge opens VIM

gitvim

提问by Shawn Mclean

I did a merge of 2 files and now Im trying to commit but it opens VIM with the following data and now I'm completely lost. (I have no experience with VIM)

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

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

What do I do from here?

我从这里做什么?

Here is the scenario:

这是场景:

I had a node.js project on github, now I'm trying to push this to nodester's git repo (so I now have 2 remotes for my project). But before I can push to nodester, I needed to fix 2 files that conflicted with the ones generated on nodester for me. I solved the conflicts with git merge -yand now I want to commit then push.

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

This is the error I get when trying to push to nodester:

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

Nodester!
To [email protected]:/node/git/lolcoder/****-**************.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:/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.

采纳答案by mattbornski

Git is opening vim because your environment variable EDITOR is set to vim, and Git believes you need to provide a commit message for the merge operation, therefore it is opening an editor for you to type one in.

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

You can fix this by changing your environment's EDITOR variable to something you prefer, or by providing a --message "this is my commit message" argument after git merge -y

您可以通过将环境的 EDITOR 变量更改为您喜欢的内容来解决此问题,或者在之后提供 --message “这是我的提交消息”参数 git merge -y

回答by Sergio Basurco

If what you want is to perform the merge and avoid opening any text editor, you can add --no-editto your merge command so that it won't open the editor for the commit message.

如果您想要执行合并并避免打开任何文本编辑器,您可以添加--no-edit到您的合并命令中,以便它不会为提交消息打开编辑器。