High quality commit messages are important for program understanding and maintenance, which describes the content of code changes. Neural-based methods are most popular ways to generate commit messages, but they neglect retrieval results including retrieval diffs and retrieval messages. The existing combination models of neural-based methods and retrievalbased methods have two major limitations: a) Only use retrieval diffs but ignore retrieval messages. b) Seldom consider the similarity and disparity between the retrieval results and given diff. To address the above two issues, we propose a retrieveguided method named ReGenSD to generate commit messages, which consists of three steps. Firstly, we apply a similaritybased IR technique to get retrieval diff and retrieval messages. Secondly, we introduce a selective mechanism to decide whether to use retrieve-guided model based on lexical similarity between retrieval diff and given diff. Lastly, for retrieve-guided model, we design a novel seq2seq network with Bi-LSTM that takes given diff, retrieval diff and retrieval message as input. We introduce a relation gate in encoder to leverage retrieval message adaptively based on semantic similarity, and a difference vector in decoder to refine the utilization of retrieval message based on semantic disparity. Experimental results on an open source dataset demonstrate that retrieval messages guidance can facilitate commit message generation task. Besides, ablation experiments prove the effectiveness of our proposed mechanisms on adjusting the use of retrieval results.