git提交远程代码时容易出现的错误
$ git push 推送代码到远程分支时,出现以下错误
Merge branch 'dev' of http://xxx into dev
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
~
原因:其他地方向同一远端库推送了代码,导致本地不是最新的。
方法一:git pull 一下即可,如果进入MERGE_MSG(linux)界面,可以ESC+:wq退出,然后git push 远程分支(但不建议这样做)
这样做不好,因为在使用 Git 的进行代码版本控制的时候,往往会发现在 log 中出现 “Merge branch ‘master’ of …” 这句话,如下图所示。日志中记录的一般为开发过程中对代码的改动信息,如果出现过多例如上述描述的信息会造成日志的污染。建议使用方法二:
方法二:git fetch + git merge + git push 远程分支(建议使用)
git提交远程代码时容易出现的错误
$ git push 推送代码到远程分支时,出现以下错误
Merge branch 'dev' of http://xxx into dev
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
~
原因:其他地方向同一远端库推送了代码,导致本地不是最新的。
方法一:git pull 一下即可,如果进入MERGE_MSG(linux)界面,可以ESC+:wq退出,然后git push 远程分支(但不建议这样做)
这样做不好,因为在使用 Git 的进行代码版本控制的时候,往往会发现在 log 中出现 “Merge branch ‘master’ of …” 这句话,如下图所示。日志中记录的一般为开发过程中对代码的改动信息,如果出现过多例如上述描述的信息会造成日志的污染。建议使用方法二:
方法二:git fetch + git merge + git push 远程分支(建议使用)