Can we sync remote repository and local repository?

Hi Team,

 

I can see that there is an option in source tree to check default remotes for updates. We can even set the time interval as well. This is a very good feature and it will notify the user that he/she require a pull. But my question is, whether this pull can also be done automatically?

i.e. When the remote repo is ahead of the local repo by 'n' number of commits, can we do a git fetch/git pull automatically, similar to the way we receive the notification.

 

Warm Regards,

-Jewel

2 answers

1 accepted

2 votes
Accepted answer

You cannot do this in SourceTree.

Workaround: write a short script that does a git pull in the right folder and schedule it to run regularly. (Even like this, you need to manually deal with the cases when there are un-pushed local commits or uncommitted changes, because the pull will fail / manual merge will be required.)

Few git clients will support automatic pulls, since they change the user's working copy, which can be confusing at best.

What happens if git pulls an update to a file while a user has unsaved changes in their IDE? Depends on the IDE. Some will discard the unsaved changes to load the updated file, some will overwrite the pulled changes when the user saves the IDE's copy that doesn't have those, some will prompt that there is a change. I don't know of any IDE that will merge changes to a local file with unsaved changes in the IDE.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

706 views 3 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you