I have cloned the required bitbucket repo in a local workstation. If there is any commit on the particular remote branch, I want it to pull automatically the latest changes. Do we have an option in source tree to set automatic git pull if there is a code change in the remote git repository for a particular branch?
Any other possible workaround is also is welcomed...!
CodePudding user response:
Git has "hooks", actions that can be executed after other actions. What you seem to be looking for is "post-receive hook". In the github admin, you can set up a post-receive url that will be hit (with a payload containing data about what was just pushed) everytime somebody pushes to your repo.
For what it's worth, I don't think auto-pull is a good idea -- what if something wrong was pushed to your branch ? I'd use a tool like capistrano (or an equivalent) for such things. referenced from: Git: auto pull from repository?
CodePudding user response:
It depends on the remote side (the one hosting your git repository)
Both Atlassian BitBucket Cloud, GitHub or GitLab allows you to define a webhook on that rpeository, allowing you locally to listen to hook events, like a push.
Your listener can then extract from the JSON payload the branch name.
And, if the name matches the branch you want to monotor, do a git pull
.