[英]How to push commit to git repository without adding Remote?
I have some repository, like 我有一些存储库,例如 https://nickname@bitbucket.org/nickname/repo-name.git . https://nickname@bitbucket.org/nickname/repo-name.git 。 I need to push some data to this repo, using Java. 我需要使用Java将一些数据推送到此仓库中。
So, basically I want to do these steps: 因此,基本上我想执行以下步骤:
But there is one problem. 但是有一个问题。 I cannot make " cd " from Java. 我无法从Java中制作“ cd ”。 So I need another solution. 所以我需要另一个解决方案。
Is there any way to push some data to repository without local git folder? 有没有办法将一些数据推送到没有本地git文件夹的存储库?
I'm not familiar with Java, so I can just give commands without cd
. 我对Java不熟悉,因此我可以不使用cd
给出命令。
git init /temp/tmp/dir
# create tmpfile.txt in /temp/tmp/dir
git --git-dir=/temp/tmp/dir/.git --work-tree=/temp/tmp/dir add tmpfile.txt
git --git-dir=/temp/tmp/dir/.git commit --message "adding tmp file"
# your question says without adding remote, so we skip "git remote add"
git --git-dir=/temp/tmp/dir/.git push https://nickname@bitbucket.org/nickname/repo-name.git HEAD:refs/heads/tmp-branch
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.