From 4d1a045280e3a55605a7dbdf4fcd4f6c5cea92c3 Mon Sep 17 00:00:00 2001 From: waylau Date: Sat, 15 Nov 2014 15:59:45 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E5=A4=84=E7=90=86=20non-fast-forward=20?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...rward errors 处理 non-fast-forward 错误.md | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Dealing with non-fast-forward errors 处理 non-fast-forward 错误.md diff --git a/Dealing with non-fast-forward errors 处理 non-fast-forward 错误.md b/Dealing with non-fast-forward errors 处理 non-fast-forward 错误.md new file mode 100644 index 0000000..ab271ad --- /dev/null +++ b/Dealing with non-fast-forward errors 处理 non-fast-forward 错误.md @@ -0,0 +1,26 @@ +Dealing with non-fast-forward errors 处理 non-fast-forward 错误 +=========== + +有时候 Git 在没有 commit 时,不能提交修改到远程库。此时, 你的 push 将会被拒绝。 + +如果另外一个人像你一样 提交 到了相同的 分支, Git 不让你提交你的change (变化): + + $ git push origin master + # To https://github.com/USERNAME/REPOSITORY.git + # ! [rejected] master -> master (non-fast-forward) + # error: failed to push some refs to 'https://github.com/USERNAME/REPOSITORY.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. + +可以在本地通过 fetch(获取) 与 merge (合并) 相同的分支的 change (变化) 来解决: + + $ git fetch origin + # Fetches updates made to an online repository + $ git merge origin branch + # Merges updates made online with your local work + +可以简单使用`git pull` 提交: + +$ git pull origin branch +# Grabs online updates and merges them with your local work \ No newline at end of file