多人協同開發,使用Git常常會看到警告信息包含術語:fast forward, 這是何義?java
簡單來講就是提交到遠程中心倉庫的代碼必須是按照時間順序的。git
好比A從中心倉庫拿到代碼後,對文件f進行了修改。而後push到中心倉庫。app
B在A以前就拿到了中心倉庫的代碼,在A push成功以後也對f文件進行了修改。這個時候B也運行push命令推送代碼。ssh
會收到一個相似下面的信息:fast-forwards' section of 'git push --help' for details. oop
chenshu@sloop2:~/work/189/appengine$ git push To ssh://csfreebird@10.112.18.189:29418/appengine.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'ssh://csfreebird@10.112.18.189:29418/appengine.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.
chenshu@sloop2:~/work/189/appengine$ git push To ssh://csfreebird@10.112.18.189:29418/appengine.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'ssh://csfreebird@10.112.18.189:29418/appengine.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.
提醒你非快進方式的更新被拒絕了,須要先從中心倉庫pull到最新版本,merge後再push.spa
fast forward可以保證不會強制覆蓋別人的代碼,確保了多人協同開發。儘可能不要使用non fast forward方法提交代碼。.net