git中最好的一个,它是分布式的。比方说,我们正在进行一个项目,所有最新的分支都会被提取并合并到我的本地存储库中。
然后服务器崩溃,没有备份,没有镜像,等等。所以中央存储库已经丢失了。
是否有可能从我的本地存储库中用所有分支恢复中央存储库?
类似于服务器上的git init --bare --shared=group ./repo.git,然后是git please --recover --with=allbraches mylocal.repository to ssh://...
发布于 2017-02-25 11:02:47
你的本地回购公司,git push origin --all。我假设还原服务器上的新回购具有相同的URL。如果URL已经更改,那么首先执行git remote set-url origin <new URL>。
发布于 2017-02-25 11:26:14
执行以下命令
# Check remote Git server.
git remote -v
# If Git server changed or doesn't exist.
git remote set-url origin your_remote_git_server
# For example.
git remote set-url origin https://github.com/donhuvy/elasticsearch.git
# Check your permission on Git server. You must be master user.
# Force push all branches to remote Git server.
git push origin --all --force
# Force push all tags to remote Git server.
git push origin --tags --force
# Check result after the above steps by few command.
git status
git branch --all
git log --oneline -10
git log --oneline --graph --decorate --all发布于 2017-02-25 11:11:09
由于您的遥控器已被移除,所以您还没有任何来源,因此您必须在服务器上创建一个新的回购程序,而不是更新您的远程url以指向新的
如果你不想要当地的分支机构,只需按下你所需要的。
这里有一张纸条,我用它来签出所有的分支,而不是把它们推到新的遥控器上。
#!/bin/bash
# update the new origin
# (or leave the same one if its the same as the original)
git remote set-url origin <new-url>
# loop over all the original branches
# 1. check them out as local branches
# 2. set the origin as the track branch
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do
git branch --track ${branch#remotes/origin/} $branch
done
# now push all branches and tags
git push origin --all
git push origin --tags剧本是做什么的?
git branch -a
获取所有本地分支的列表。
| grep remotes分支名称是:' remotes /origin/‘,因此这将从分支名称中移除远程
| grep -v HEAD | grep -v master
删除主(当前分支)和HEAD,这是最新提交的别名
https://stackoverflow.com/questions/42455167
复制相似问题