Reputation: 1799
Is there any way to push an empty commit to a (remote) git repository without cloning the git repository first?
I.e., can I achieve the effect of
git clone https://github.com/example-org/example-repo.git
cd example-repo
git commit -m "empty commit" --allow-empty
git push
without first cloning the repository in the first line?
Ideally, I'd like to do this with "pure" git, but using the github API would be fine as well if there no easy way for pure git.
Background: I need the empty commit as part of the automatic deploy mechanism in Heroku which automatically deploys on github commits.
Upvotes: 0
Views: 1739
Reputation: 44970
Assuming that your concern is time and resources spent downloading the repository content you can use a shallow clone with git clone --depth 1
option.
As per clone
docs:
--depth <depth>
Create a shallow clone with a history truncated to the specified number of commits. Implies
--single-branch
unless--no-single-branch
is given to fetch the histories near the tips of all branches. If you want to clone submodules shallowly, also pass--shallow-submodules
.
There is also git clone --bare
approach as explained in this answer but you would have to setup origin manually before pushing.
Upvotes: 2