1

I've created a deployment tool for colleagues (developers) to simply press a button to deploy code from bitbucket to a remote server. Two things will occur

  1. SSH into server (target address)
  2. Run a git command here to pull the code

The problem lies in my lack of git knowledge. Repositories may have tags and so there is more to this than just 'git pull'. Presuming the repo has already been cloned, so it exists, how would I pull code to the server using a specific tag?

One thing I was thinking is that latest tags that people create on bitbucket may not exist on the server, so when they deploy and enter this tag, how will the server know this tag exists? Will I need to pull all and then pull the specific tag?

I figure these 3 are what I may possibly need - pull, fetch, checkout.

What would be the best git command(s) to ensure a remote server can pull the correct code from a specified tag, even if the repo has been heavily updated and new tags added?

Conor
  • 721
  • 1
  • 6
  • 18

1 Answers1

2

You can do (since git 1.9)

cd /path/to/repo
git fetch --tags
git checkout atag

That will leave you in a detached HEAD mode, but that might not matter in your context.

See "Does “git fetch --tags” include “git fetch”?"

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250