Is there a way to push a commit to a remote git repo, without first making a local clone of that repo?
I have a valid URL for the remote repo, I know the path of the
No, I don't think that's possible. You need to clone the whole repository for this to work. Git needs to know about all the files and .git
to do its job correctly. This is why you can't just push arbitrary files like that.
@algal, for your particular use-case, you might be able to use a submodule (http://git-scm.com/docs/git-submodule). You could clone and commit to the submodule, w/o cloning the "supermodule" which could contain the "massive" code you mentioned. The supermodule could reference the submodule for the config info you mentioned.
Well, if you use GitHub, then you could do this easily with GitHub API
https://developer.github.com/v3/repos/contents/#create-or-update-a-file
Basically you do:
Create OAuth App and get Access Token
https://developer.github.com/apps/building-oauth-apps/
Make request to GitHub API:
Set Authorization header with your Access Token (OAuth 2.0)
PUT https://api.github.com/repos/:owner/:repo/contents/:path
with JSON body like this:
{
"message": "my test commit through API",
"content": "QmFzZTY0IGVuY29kZWQgY29udGVudCBoZXJl",
"sha": "cd220ncv229f2e4a95bce426ff48b1ae6b885b3a42"
}
Where:
message - your commit message
content - updated content encoded in Base64 format
sha - sha for updating file, you can get it by API request
GET https://api.github.com/repos/:owner/:repo/contents/:path
:owner - repository owner
:repo - repository name
:path - path to file within repository
Example request:
https://api.github.com/repos/nodejs/node/contents/README.md
Just discovered this issue and thought of an update.
If you're using github just prefix your repo url with https://gitpod.io#.
It's a service that allows you to update your repo online, so you can update files without cloning locally.
Yes you can push a new version using tagging
follow this steps
in your new project root
git init
git remote add origin git@github.com:yourusername/yourpoject
git tag -a v2.0 -m 'version 2.0'
git add .
git commit -m "New Version 2.0 :rocket:"
git push -u origin v2.0
now you have a new branch called v2.0 with your new project and your master branch stays untouched. After that if you wan't you can change your default branch in your github project settings.
Impossible. But since a prospective commit would just need to have one single commit as its parent it's possible to employ the so-called "shallow cloning" and fetch just the tip commit of the branch you need. This will bring only a minimum amount of objects from the remote. Look for the --depth
command-line option of git clone
.