I'm trying to create a branch from a remote tag, but it seems there's no way to do it. When I try
git checkout -b test origin/deploy
where origin is the remote and deploy is the tag I want to check out, but I get
fatal: git checkout: updating paths is incompatible with switching branches. Did you intend to checkout 'origin/deploy' which can not be resolved as commit?
UPDATE: I've just discovered that
git fetch --all -t
was not working properly for me. While it downloads all branches, it does not download all tags, so when I checked out deploy it was and old tag. Now I execute
git fetch --all && git fetch -t
This way when I create a new branch based on a tag
git checkout -b test deploy
the new branch is up to date with the last deploy.
Git Checkout a Remote Branch Each remote repository will contain its own set of branches. In order to checkout a remote branch you have to first fetch the contents of the branch. In modern versions of Git, you can then checkout the remote branch like a local branch.
If you want to check out a remote branch someone published, you first have to use git fetch . This command downloads the references from your remote repository to your local machine, including the reference to the remote branch. Now all you need to do is use git checkout <remote branch name> .
I'm not sure you can do this directly. You're probably stuck with doing a fetch and then a checkout:
git fetch origin git checkout -b test tag-name
By the way, I wouldn't recommend using a tag name like "deploy".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With