Git 如何将所有分行推送到新创建的回购
我们正在将回购协议从gitlab转移到github 一个小型CI脚本负责传输,但由于某些原因,我们无法发送所有分支:Git 如何将所有分行推送到新创建的回购,git,github,gitlab,push,Git,Github,Gitlab,Push,我们正在将回购协议从gitlab转移到github 一个小型CI脚本负责传输,但由于某些原因,我们无法发送所有分支: async function gitlabToGithub({ name, organization, token, travisToken, branches, // eslint-disable-line no-unused-vars origin, path, remove, exclude, tags, }, cb) { try
async function gitlabToGithub({
name,
organization,
token,
travisToken,
branches, // eslint-disable-line no-unused-vars
origin,
path,
remove,
exclude,
tags,
}, cb) {
try {
if (remove) {
await execa.shell(`curl -X DELETE -H 'Authorization: token ${token}' https://api.github.com/repos/${organization}/${name}`);
}
console.log(`Creating repository ${organization ? `${organization}/${name}` : name}`);
const {
html_url: htmlUrl,
clone_url: cloneUrl,
} = await createGitHubRepoPromise({ name, organization, token });
const repo = htmlUrl.replace('https://github.com/', '');
const remote = cloneUrl.replace('github.com', `${token}@github.com`);
console.log('Activating travis');
await activateTravisLoop({ repo, token });
await execa.shell('sleep 7s');
await syncTravisLoop({ token: travisToken });
try {
await execa.shell(`git -C ${path} remote add ${origin} ${remote}`);
} catch (e) {
await execa.shell(`git -C ${path} remote set-url ${origin} ${remote}`);
}
console.log(`Remote ${origin} configured for GitHub.`);
console.log(`git -C ${path} fetch --all`);
const { stdout: un } = await execa.shell(`git -C ${path} fetch --all`);
console.log(un);
console.log(`git -C ${path} branch -l`);
const { stdout: unBisZero } = await execa.shell(`git -C ${path} branch -l`);
console.log(unBisZero);
console.log(`git -C ${path} branch -r`);
const { stdout: unBis } = await execa.shell(`git -C ${path} branch -r`);
console.log(unBis);
// console.log(`git -C ${path} push ${origin} ${branches.join(' ').trim()}`);
// const { stdout: deux } = await execa.shell(`git -C ${path} push ${origin} ${branches.join(' ').trim()}`);
// console.log(deux);
console.log(`git -C ${path} push ${origin} '*:*'`);
const { stdout: deux } = await execa.shell(`git -C ${path} push ${origin} '*:*'`);
console.log(deux);
if (tags) {
console.log(`git -C ${path} push --tags`);
const { stdout: trois } = await execa.shell(`git -C ${path} push --tags`);
console.log(trois);
}
if (exclude.length) {
Promise.all(exclude.split(',').map((branch) => execa.shell(`git -C ${path} push ${origin} --delete ${branch}`).then(execa.shell(`git -C ${path} branch -D ${branch}`)))).then(() => {
console.log(`git -C ${path} remote rm ${origin}`);
execa.shell(`git -C ${path} remote rm ${origin}`).then(() => {
if (cb) {
cb();
}
}).catch((e) => {
console.log('[ERROR] ', e.message);
throw e;
});
}).catch((e) => {
console.log('[ERROR] ', e.message);
throw e;
});
}
} catch (e) {
console.log('[ERROR] ', e.message);
throw e;
}
}
我们已经尝试了很多选项,git push${remote}-all,git push${remote}*/*,以前都做过git fetch-all。没有什么真正的帮助
Creating repository bootstrap-styled/navigation-bar
Activating travis
Travis activated
Travis synced
Remote github configured for GitHub.
git -C /mnt/mesos/sandbox/builds/bootstrap-styled/navigation-bar fetch --all
Fetching origin
Fetching github
git -C /mnt/mesos/sandbox/builds/bootstrap-styled/navigation-bar branch -l
* (detached from 26957f2)
github-snapshot
master
git -C /mnt/mesos/sandbox/builds/bootstrap-styled/navigation-bar branch -r
github/github-snapshot
origin/0.0.4
origin/0.0.5
origin/1.0.0
origin/1.0.1
origin/1.0.2
origin/1.1.3
origin/1.1.4
origin/1.1.5
origin/1.1.6
origin/HEAD -> origin/master
origin/agd-dev
origin/ajt-dev
origin/dev
origin/github-snapshot
origin/master
origin/v0.0.1
origin/v0.0.2
origin/v0.0.3
git -C /mnt/mesos/sandbox/builds/bootstrap-styled/navigation-bar push github '*:*'
git -C /mnt/mesos/sandbox/builds/bootstrap-styled/navigation-bar push --tags
[Success] repository created and configured for travis
git -C /mnt/mesos/sandbox/builds/bootstrap-styled/navigation-bar remote rm github
有人知道我如何做到100%的成功率吗?我想你想得太多了。有没有理由-mirror不做这项工作
git clone --mirror old-url
# cd into the newly-clined repo
git push --mirror new-url
git推镜?前提是您首先跟踪了远程分支