正在用新的本地副本替换 Git 存储库
Replacing Git Repository with a new Local Copy
我有一个 QA 环境,它有一个以前版本的转换 hg 存储库存储在 git 存储库中。出于测试目的,我需要重新 运行 转换(使用 git-remote-hg)并将过去几周所做的所有更改推送给我们的 QA git环境。
如果我需要的所有历史记录都在本地副本中,如何在不删除远程存储库的情况下用我的本地存储库替换整个远程存储库?
可以强制推送。
推送特定分支,
git push --force <remote> <branch>
推送两端同名的所有分支(如果push.default
设置为matching
),
git push --force
这将用您的本地分支覆盖远程分支。
在 运行 命令之前请注意您想要实现的目标。您将丢失提交。
根据文档,
Usually, the command refuses to update a remote ref that is not an
ancestor of the local ref used to overwrite it. This flag disables the
check. This can cause the remote repository to lose commits; use it
with care.
更新
master
分支强制推送完成后,可以推送所有远程不在的本地分支,
git push <remote> --all
我有一个 QA 环境,它有一个以前版本的转换 hg 存储库存储在 git 存储库中。出于测试目的,我需要重新 运行 转换(使用 git-remote-hg)并将过去几周所做的所有更改推送给我们的 QA git环境。
如果我需要的所有历史记录都在本地副本中,如何在不删除远程存储库的情况下用我的本地存储库替换整个远程存储库?
可以强制推送。
推送特定分支,
git push --force <remote> <branch>
推送两端同名的所有分支(如果push.default
设置为matching
),
git push --force
这将用您的本地分支覆盖远程分支。
在 运行 命令之前请注意您想要实现的目标。您将丢失提交。
根据文档,
Usually, the command refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. This flag disables the check. This can cause the remote repository to lose commits; use it with care.
更新
master
分支强制推送完成后,可以推送所有远程不在的本地分支,
git push <remote> --all