簡體   English   中英

合並后 Git Commit 打開 VIM

[英]Git Commit after merge opens 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

我從這里做什么?

這是場景:

我在 github 上有一個 node.js 項目,現在我正在嘗試將它推送到 nodester 的 git repo(所以我現在有 2 個項目的遙控器)。 但是在我可以推送到 nodester 之前,我需要修復 2 個與在 nodester 上為我生成的文件沖突的文件。 我用git merge -y解決了沖突,現在我想提交然后推送。

這是我嘗試推送到 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 正在打開 vim,因為您的環境變量 EDITOR 設置為 vim,並且 Git 認為您需要為合並操作提供提交消息,因此它正在打開一個編輯器供您輸入。

您可以通過將環境的 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