简体   繁体   English

将git提交到远程存储库,而无需克隆任何本地存储库

[英]Commit git to remote repository without cloning any local repository

My question is quite simple, however I don't find any answer on StackOverflow or elsewhere (except this question but without being answered): 我的问题很简单,但是我在StackOverflow或其他地方找不到任何答案(除了这个问题,但没有得到回答):

Does anyone know a way to commit a GIT change "directly" to a remote repository (Github in my case) without cloning the repository in local and having to commit first to local repository then pushing to remote? 有谁知道一种将GIT更改“直接”提交到远程存储库(在我的例子中是Github)而无需在本地克隆存储库而必须先提交到本地存储库然后再推送到远程的方法吗?

Commits will be performed programmatically from Python (by using simply GIT command lines). 提交将通过Python(仅使用GIT命令行)以编程方式执行。 Honestly I don't see the advantage (in my case) of having a separate server (for local repos) and keep huge git repository on it just to push them finally to Github. 老实说,我看不到有一个单独的服务器(用于本地存储库)并在其上保留巨大的git存储库,只是最终将它们推到Github的优势。

You can clone the repo with -n to not checkout any files. 您可以使用-n克隆存储库,以不检出任何文件。
--depth 1 will truncate the history of each file to their last commit --depth 1将截断每个文件的历史记录到最后一次提交

git clone -n git://path/to/repo.git --depth 1

cd repo

Checkout only the files you need to change for your commit 仅签出您需要更改以提交的文件

git checkout HEAD file.ext

Just be careful to only commit the file you're working on. 请注意只提交您正在处理的文件。 If you do something like git add . 如果您执行git add . you will be committing the deletion of all files you have not checked out! 您将删除所有尚未签出的文件!

You cannot create commits by using Git command line tools (Python or not doesn't matter) — those tools require a local repository and most of them require a local checkout (work tree). 您不能使用Git命令行工具(是否使用Python无关紧要)来创建提交-这些工具需要本地存储库,并且其中大多数需要本地签出(工作树)。

You can create commits using Github API but this is much harder and you need completely different set of tools like or any other Python Github API wrapper. 您可以使用Github API创建提交,但这要困难得多,并且您需要完全不同的工具集,例如或任何其他Python Github API包装器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将文件从 web 应用程序(弹簧启动)提交到 git 远程存储库,而不首先将存储库克隆为本地? 这可能吗 - commit file from a web application (spring boot) into git remote repository without first cloning the repo as local? is this possible 如何在不丢失本地存储库中的任何更改的情况下删除 GIT 中的提交消息并将其推送到远程存储库? - How to delete commit messages in GIT without losing any changes in local repository and push the same to remote repository? 标记远程git存储库而不克隆它 - Tag a remote git repository without cloning it 无需克隆即可访问远程存储库的 Git API - Git API to access a remote repository without cloning it 自上次检查以来,检查远程git存储库是否有任何更改,而无需克隆存储库 - Check if remote git repository has any changes since last check without cloning repository "通过 1 次提交回滚本地和远程 git 存储库" - Rolling back local and remote git repository by 1 commit Git和TortoiseSVN,我如何撤消本地存储库中的更改,而无需再次克隆远程仓库 - Git and TortoiseSVN, how do i undo my changes in local repository without cloning the remote repo again 列出来自特定分支的 Git 提交 SHA,而不克隆存储库 - List Git commit SHAs from a specific branch without cloning the repository 无需克隆即可获取Github存储库的最新git commit哈希 - Retrieve latest git commit hash of a Github repository without cloning Git推送到远程存储库,丢弃最新提交并替换为本地提交 - Git push to a remote repository, discard the latest commit and replace with local commit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM