合并后Git Commit打开VIM

发布于 2025-01-03 13:09:43 字数 1884 浏览 3 评论 0原文

我合并了 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

我该怎么办?

场景如下:

我在 github 上有一个 node.js 项目,现在我正尝试将其推送到 Nodester 的 git 存储库(所以我的项目现在有 2 个遥控器)。但在推送到 Nodester 之前,我需要修复 2 个与 Nodester 上生成的文件冲突的文件。我用 git merge -y 解决了冲突,现在我想提交然后推送。

这是我尝试推送到 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.

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)

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 -y and now I want to commit then push.

This is the error I get when trying to push to 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

眼角的笑意。 2025-01-10 13:09:44

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

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

情愿 2025-01-10 13:09:44

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

export GIT_MERGE_AUTOEDIT=no

If you wish to totally skip the text editor and use the default merge message instead, just add the following line into your .bash_profile, .bashrc or .zshrc file:

export GIT_MERGE_AUTOEDIT=no
贱人配狗天长地久 2025-01-10 13:09:43

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

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

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.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文