Git 关于Fast Forward提交的简单说明

多人协同开发,使用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

 

http://blog.csdn.net/csfreebird/article/details/7916625code

相关文章
相关标签/搜索