如何在另一个git仓库中提交一个git仓库

如何在另一个git仓库中提交一个git仓库

本文介绍了如何在另一个git仓库中提交一个git仓库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用git的应用程序,所以我需要测试它与git的集成。在我的git仓库中,我需要另一个仓库(my_git_repo / tests / another_repo)。我怎么能没有git submodules提交它? (我不想有另一个远程仓库(在github / bitbucket等)只有一个文件)



任何想法?

解决方案

子模块不一定需要单独克隆;您可以在单个回购库中发布项目及其子模块。只需要有一个专门用于主要repo中子模块内容的分支,然后直接从那里克隆主repo git clone -sb 子模块。

 #以这种方式设置您当前的回购:
(git init sub
cd sub
>文件
git add。
git commit -m-
git remote add origin ..
git push -u origin master:sub / master

新克隆中的设置:

  git分支-t子/主起源/子/主
git克隆-sb子/主。 sub

sub 将会有最新的内容。

git rev-parse:sub 会显示为 sub - 即应该检查那里 - 当你不只是想要当前的分支小费。



你可以连接 git submodule 命令在这里有一个 .gitmodules 文件以及这个和那个,但它似乎不值得。


I'm developing an application that uses git, so I need to test its integration with git. Inside my git repository, I need to have another repository (my_git_repo/tests/another_repo). How can I commit it without git submodules? (I don't want to have another remote repository (in github/bitbucket, etc) for just one file)

Any ideas?

解决方案

Submodules don't necessarily need to be cloned separately; you can publish a project and its submodules in a single repo. Just have a branch dedicated to the submodule contents in your main repo, then after cloning the main repo git clone -sb the submodule directly from there.

# setup your current repo this way:
( git init sub
  cd sub
  > file
  git add .
  git commit -m-
  git remote add origin ..
  git push -u origin master:sub/master
)

Setup in new clone:

git branch -t sub/master origin/sub/master
git clone -sb sub/master . sub

and sub will have the most recent content.

git rev-parse :sub will show you what's committed for sub -- i.e. what should be checked out there -- when you don't just want the current branch tip.

You could hook up the git submodule command here, with a .gitmodules file and this and that, but it hardly seems worth it.

这篇关于如何在另一个git仓库中提交一个git仓库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 05:35