search

Home  >  Q&A  >  body text

What to do if the git tags and branches have the same names?

For example, there is a tag called v1 and a branch also called v1, but they point to different commits. How do I distinguish the tag and branch when I checkout?

PHP中文网PHP中文网2811 days ago1332

reply all(2)I'll reply

  • 为情所困

    为情所困2017-05-02 09:43:39

    First of all, be sure not to use tags and branches with the same name. This will put the entire project team into the dilemma of "can you tell whether I am male or female".

    "Unified naming standards are important! Unified naming standards are important! Unified naming standards are important!"

    I really don’t know how to name it more appropriately. You can refer to Git FLOW

    In addition, if there is a duplicate name, there are two ways to rebuild a branch with a meaningful name to solve the problem

    git checkout -b new_branch old_branch 
    
    git checkout -b new_branch <sha1>
    

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-02 09:43:39

    git checkout tags/v1

    reply
    0
  • Cancelreply