将单个提交推送到git远程存储库(无历史记录或合并本地提交)

编程入门 行业动态 更新时间:2024-10-28 15:28:35
本文介绍了将单个提交推送到git远程存储库(无历史记录或合并本地提交)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我具有以下基于git的结构:

I have a following, git based structure:

  • 本地存储库#1,其中大部分开发工作已完成
  • 远程存储库#1,我将所有提交都推送到其中,我们称之为开发仓库"
  • 远程存储库#2,我只想存储一些提交,完全独立于 本地(以及开发)存储库历史记录,我们称其为生产存储库"
  • local repository #1, where most of the development is done
  • remote repository #1, where I push all the commits, lets call it "development repo"
  • remote repository #2, where I want to store only some commits, completely independent to the local (as well as development) repositories history, lets call it "production repo"

我的问题是,在以下假设的情况下,如何使它容易工作?

My question is, how can I easily make it works, with following assumptions:

  • 生产仓库仅应包含选定的提交(我使用一些特殊命令来提交)
  • 开发仓库是一个常规"远程存储库,我可以在其中存储整个历史记录
  • 本地存储库包含所有历史提交,因此不允许挤压其提交

我知道,这不是一个不错的概念",并且我可以通过其他存储库的设计获得类似的结果,但是我的问题不是这个想法,而是使用现有工具实现此结果的可能性.

I am aware, that this is not a "nice concept", and that I could achieve similar results by other repositories' design, but my question is not about the idea, but the possibility of achieving this result with existing tools.

我目前使用以下bash脚本来执行此操作.当我想提交到生产仓库"时,只需运行脚本,然后像往常一样使用开发仓库.

I currently use the following bash script to do it. When I want to commit to the "production repo" simply run the script, and a development repo is used as usual.

#!/bin/bash # $1 - local repository directory # $2 - local repository name # $3 - production (remote) repository # $4 - init or push # $5 - message tmpmaindir="/tmp" tmpdir="gitresync" # creating temp env cd $tmpmaindir mkdir $tmpdir cd $tmpdir if [ $4 = "init" ]; then #creating prod repo cp -r $1 . cd $2 rm -rf .git git init git add '*' git commit -m "$5" git remote add origin $3 git push -u origin master else # pushing to existing prod repo git clone $3 rsync -av --exclude='.git' $1 . cd $2 git add '*' git commit -m "$5" git push $3 fi # cleaning cd $tmpmaindir rm -rf $tmpdir 2> /dev/null

使用纯git工具能否实现?还是至少没有创建临时文件和本地存储库?

Is it possible to achieve with pure git tools? Or at least without creating a temporary files and local repositories?

推荐答案

git tag alz-v4.6 $(git commit-tree -m'foo' someref^{tree}) git push dropbox-repo alz-v4.6

更多推荐

将单个提交推送到git远程存储库(无历史记录或合并本地提交)

本文发布于:2023-10-06 17:47:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1467609.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:历史记录   git

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!