We have investigated the generation of new dislocations during the epitaxial growth of 4H-SiC layers. Dislocations were mainly propagated from the substrate into the epitaxial layer. However, it was found that some amount of new threading edge dislocations (TEDs) and basal plane dislocations (BPDs) were generated during the epitaxial growth. The generation of those dislocations appeared to depend on the in-situ H2 etching conditions, not the epitaxial growth conditions. By optimizing in-situ H2 etching condition, we were able to effectively suppress the generation of new dislocations during epitaxial growth, and obtain 4H-SiC epitaxial layers which have the equivalent etch pit density (EPD) to the substrates. Our additional investigation of the conversion of BPDs to TEDs revealed that its efficiency similarly depends on in-situ H2 etching. We were able to obtain a high conversion efficiency of 97 % by optimizing the in-situ H2 etching conditions before epitaxial growth.