asteroid4u
asteroid4u

Reputation: 135

Bitbucket auto pull latest code from remote repository

We have Bitbucket cloud remote Server.

I have hundreds of servers and I have to fetch the latest code from the repository.

I have found below commands to fetch the latest code from the remote server.

git fetch origin
git diff origin/master
git merge origin/master

I am very new to Git world.

Is there way we can automate this task in bitbucket portal like every hour pull latest code from remote repository?

All Servers are configured with passwordless ssh connection to remote bitbucket server.

I can add above fetch commands in crontab in all the servers. But i am thinking there may be easy steps to achieve my requirement.

Upvotes: 2

Views: 1275

Answers (1)

CodeWizard
CodeWizard

Reputation: 142352

Git does not pull data by itself so you have to initiate the pull your self.

As you described you can do the git fetch and adding --all will fetch all the remotes at once.

Instead of executing the 3 command you can simply run a single command:

# pull = fetch + merge
# get all the delta from the server and merge it into the local branch
git pull <remote> <branch name>

The best solution is to add the script to your crontab and execute it every hour

Upvotes: 2

Related Questions