git - 移动远程分支

标签 git version-control

rewriting the commit tree to rename the author and change the email 之后,我的本地仓库和远程源不同步。我是唯一的开发人员,想将我的本地仓库推送到 origin,将 origin/master 更新到我的本地 master 分支。这是我尝试过但没有成功的方法:

LibGuest08@LBP-NW0345QZMH1 /e/devel/src/java/bbct (swing.0.5.2)
$ git push
Password:
To ssh://codeguru@git.code.sf.net/p/bbct/code
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'ssh://codeguru@git.code.sf.net/p/bbct/code'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. If you did not intend to push that branch, you may want to
hint: specify branches to push or set the 'push.default' configuration
hint: variable to 'current' or 'upstream' to push only the current branch.

LibGuest08@LBP-NW0345QZMH1 /e/devel/src/java/bbct (swing.0.5.2)
$ git push origin master:master
Password:
To ssh://codeguru@git.code.sf.net/p/bbct/code
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'ssh://codeguru@git.code.sf.net/p/bbct/code'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and merge the remote changes
hint: (e.g. 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

LibGuest08@LBP-NW0345QZMH1 /e/devel/src/java/bbct (swing.0.5.2)
$ git push -f origin master:master
Password:
Counting objects: 464, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (148/148), done.
Writing objects: 100% (452/452), 470.65 KiB, done.
Total 452 (delta 268), reused 417 (delta 247)
remote: error: denying non-fast-forward refs/heads/master (you should pull first)
To ssh://codeguru@git.code.sf.net/p/bbct/code
 ! [remote rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'ssh://codeguru@git.code.sf.net/p/bbct/code'

LibGuest08@LBP-NW0345QZMH1 /e/devel/src/java/bbct (swing.0.5.2)
$

我也按照建议提取了 origin,但这确实与所有提交 merge ,其中一些提交有错误的作者姓名和电子邮件。如何将我的远程源存储库与我的本地存储库同步并删除所有包含错误元数据的提交?

更新:

我编辑了 Sourceforge 存储库中的配置文件。我仍然收到一条错误消息,但我注意到另一行:

lib_lab_ref08@LBP-REF87XVMDP1 /e/devel/src/java/bbct (master)
$ git push -f
Password:
Counting objects: 464, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (148/148), done.
Writing objects: 100% (452/452), 470.65 KiB, done.
Total 452 (delta 268), reused 417 (delta 247)
fatal: Unable to create temporary file: Permission denied
error: unpack failed: index-pack abnormal exit
To ssh://codeguru@git.code.sf.net/p/bbct/code
 ! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to 'ssh://codeguru@git.code.sf.net/p/bbct/code'

什么是

fatal: Unable to create temporary file: Permission denied
error: unpack failed: index-pack abnormal exit

是什么意思?更重要的是,我该怎么做才能解决这个问题?

经过思考:

我使用的是公用计算机。我最近压缩了我的 repo 数据库,我猜我没有权限写入 git 在推送过程中解压缩压缩的 repo 对象的临时文件夹。我将在没有这些安全限制的计算机上尝试此操作,看看会发生什么。

最佳答案

远程存储库上有一个设置可以防止(这是一件好事)非快进推送,这就是您正在执行的推送类型。

正如您指出的那样,您可以安全地进行非 ff 推送,因为您是唯一使用它的人,因此请参阅 this blog post查看如何更改它:

  1. 使用ssh -t USER,PROJECT@shell.sourceforge.net create登录ssh shell
  2. 导航到 git 存储库:cd 到 /home/git/p/<project_name>/code.git (填写正确的项目名称)
  3. vi编辑配置文件并设置 denyNonFastforwardsfalse

关于git - 移动远程分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12449230/

相关文章:

git - 错误: src refspec my-branch does not match any

git - 为什么git修改一个分支也会修改另一个分支

windows - 如何在 Windows 上运行 Git 服务器?

deployment - 如何将版本控制系统修订与 Docker 镜像版本同步?

git - 如何在 svn 中获取本地根路径?

version-control - 如何忽略本地存储库中的 .hgignore?

git - JGit HTTPS 克隆不起作用

git - .gitignore 文件的对面?

version-control - Perforce:我可以在文件上放置 'watch',以便在文件更改时收到通知吗?

android - Git中的Android构建版本自动化