简体   繁体   English

合并后 Git Commit 打开 VIM

[英]Git Commit after merge opens VIM

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.我合并了 2 个文件,现在我尝试提交,但它用以下数据打开 VIM,现在我完全迷失了。 (I have no experience with 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).我在 github 上有一个 node.js 项目,现在我正在尝试将它推送到 nodester 的 git repo(所以我现在有 2 个项目的遥控器)。 But before I can push to nodester, I needed to fix 2 files that conflicted with the ones generated on nodester for me.但是在我可以推送到 nodester 之前,我需要修复 2 个与在 nodester 上为我生成的文件冲突的文件。 I solved the conflicts with git merge -y and now I want to commit then push.我用git merge -y解决了冲突,现在我想提交然后推送。

This is the error I get when trying to push to nodester:这是我尝试推送到 nodester 时遇到的错误:

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.

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 变量更改为您喜欢的内容来解决此问题,或者在git merge -y之后提供 --message “这是我的提交消息”参数

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

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

export GIT_MERGE_AUTOEDIT=no

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM