How to check if remote branch exists on a given remote repository?

后端 未结 14 1024
独厮守ぢ
独厮守ぢ 2020-12-02 11:04

I need to do a subtree merge for a specific branch, if it exists on a given remote repository. The problem is that the remote repository is not checked out locally, so I can

14条回答
  •  执念已碎
    2020-12-02 11:38

    You can add the repository you have as a remote using git remote add something https://github.com/project-name/project-name.git and then do a git remote show something to get all information about the remote. This requires a network connection and is useful for human use.

    Alternatively, do a git fetch something. This will fetch all branches on the remote called something and keep them in your local repository. You can then merge them into your local branch as you please. I recommend this path since if you finally decide that you have to merge, this is what you need to do.

    OT: Your use of "checked out locally" indicates that you're approaching this from a centralised version control system standpoint. That's usually a dead end when you're dealing with git. It uses words like "checkout" etc. differently from how older systems did.

提交回复
热议问题