I´m trying to do an update of my local repository.
According to the documentation, doing a fetchAll fetches all branches from the remote, which is what I´m currently doing. There is nothing like pullAll which automatically merges those remotes with my local ones.
My idea now was to get all branches after doing a fetchAll
gitUpdate(url, options, repositoryPath, callback) {
let repository = undefined;
NodeGit.Repository.open(repositoryPath)
.then(function (repo) {
repository = repo;
return repo.fetchAll(options.fetchOpts);
})
.then(function () {
return repository.getReferenceNames(NodeGit.Reference.TYPE.LISTALL);
})
.then(function (branches) {
/*
[ 'refs/heads/test',
'refs/heads/master',
'refs/remotes/origin/master',
'refs/remotes/origin/test' ]
*/
return console.log("branches", branches);
})
.then(function (fetched) {
callback(null, fetched);
}, function (err) {
callback(err);
});
};
then iterate over them, filtering out matching ones and doing some string stuff to fit them into repository.mergeBranches("master", "origin/master");
While doing that I´m just thinking this can´t be seriously the way to go and there must be a shortcut somehow.
How do I simply sync the local repository with the remote one, including all branches, without cloning the repository again?